aws-lambda-image
aws-lambda-image copied to clipboard
reduce and resize
I need some clarification about the config file.
Given this configuration:
{
"acl": "public-read",
"reduce": {
"quality": 60,
"suffix": "_reduced"
},
"resizes": [
{
"size": 200,
"suffix": "_resized"
}
]
}
It is intended that for an image MyImage.jpg the lamda reduce and resize it so that I should obtain two new images in the same folder.
-
MyImage_reduced.jpg
-
MyImage_resized.jpg
Is this correct? Because right now I get only the reduced image.
thx
Your config file seems to be working fine for me. I would suggest checking Lambda Monitoring and CloudWatch, cause I guess Timeout parameter is se to too small value and resizing process is breaking in the middle of processing second file.
I had to do a change in the code. In ImageProcessor.js there is a condition that excludes file in the current directory and in my case they happens to be in the same folder (original file and resized/resample). Removing that filter works for me.
I agree that this part could be problematic (especially because lack of logging), I had some problems with it to. Purpose of this part of code is to disallow outputting processed files in the same directory structure. It was implemented that way (I guess), because S3 event handlers are "stupid" and each processed and saved in the same path (incl. sub-directories) file will make the Lambda to invoke again, for new file this time. This could lead to never ending loop, but(!) there is another safeguard in place, so the lines you pointed out seems to be redundant now. We will just need to figure out how to deal with this cases.