Background (node) uses images module to process clipped pictures

upload pictures from the foreground and clip using jcrop. Cutting data passed to the background

    imgData.x=c.x;
    imgData.y=c.y;
    imgData.w=c.w;
    imgData.h=c.h;

Parameter information obtained after receiving in the background

 { imgcutX: "19",
  imgcutY: "47",
  imgcutW: "104",
  imgcutH: "132",
  imgOriginWH: "463,462" }
 [ { fieldname: "f1",
    originalname: "timg.jpg",
    encoding: "7bit",
    mimetype: "image/jpeg",
    destination: "./static/upload",
    filename: "53e5b756556f916424bd33e8425c77b0",
    path: "static\\upload\\53e5b756556f916424bd33e8425c77b0",
    size: 4129 } ]
    

Code for processing part:

    var patharr=req.files[0].path.split("\\")
    patharr.pop();
    var newP=patharr.join("\\")+"\\";
    var picName=new Date().getTime()+pathLib.parse(req.files[0].originalname).ext
    var newfileName=newP+picName
    fs.rename(req.files[0].path,newfileName,function(err){
        if(err){
          console.log("")
          return;
          res.status(500).send("").end();
        }else{
           images(images("./static/upload/"+picName),req.body.imgcutX,req.body.imgutY,req.body.imgcutW,req.body.imgcutH).resize(100).save("./static/upload/n-"+picName)
        }
        

instead of cropping the picture, it compresses the whole picture into such a small size. Is it the wrong images? Or is there something wrong with the data sent by the front desk? I hope the boss will answer.

Mar.10,2021

can be sure that the backend images is used correctly. Why don't you take a look at the size of the picture coming from the front and so on.

Menu