Using node-imagemagick to 'crop' an image uploaded to S3
-
14-06-2021 - |
Question
I'm building functionality that allows users to upload an image, then crop it to a square (for profile pictures etc...)
Currently, the process works like this:
- User selects image from hd
- Image is uploaded to S3
- S3 Path is sent back to view, and image with jCrop is shown
- On submit button being clicked, my controller action gets the coords set above
Now I'd like to crop this image to the given coords (note- I'm using lpatters fork of node-imagemagick as it contains 'offset'
Unfortunately, .crop only accepts a path - which we don't have, since it's hosted on S3 at this point.
Is there any workaround?
I saw tmp, but this may be a little overkill?
La solution
What about using some of the other entry points such as "resize" that then allow you to provide the custom arguments? I'm using streams in this code: https://github.com/jeffwilcox/4th-cloud/blob/master/lib/webserver.js#L542
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow