Express JS : image cropping failed on large sized images

95 views Asked by At

I have an image uploading system(Upload image to AWS s3) and cropping image into various cropped sizes after upload

But the image cropping is failed while upload large images there is no memory leak issue in but i got 0 byte image in s3 bucket.

Here is the code

var crop_sizes = [
    //android images
    {
        max_width:600,
        max_height:600,
        folder:'android/list/',
        is_fixed:false
    },
    {
        max_width:1600,
        max_height:1200,
        folder:'android/full-screen/',
        is_fixed:false
    },.......
]

for (var i=0;i<crop_sizes.length;i++){
   //run crop function
   crop(crop_sizes[i]);   
}

function crop(crop_sizes){

 gm(path)
    .resize(width, height,'^')
    .stream(function (err,buffer) {
         if(err) throw err;
          s3Upload(buffer,folder,key,s3)
        });

}

For smaller size images there is no problem but when i upload larger image crop is failed i think there is a bottleneck in my code but i can't find it

0

There are 0 answers