Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Default Image Fallback #137

Closed
mberneis opened this issue Jul 27, 2019 · 11 comments
Closed

Feature Request: Default Image Fallback #137

mberneis opened this issue Jul 27, 2019 · 11 comments

Comments

@mberneis
Copy link

It would be great if one could provide a default fallback image URL in case the image processing is not able to handle the incoming image.

Or at least supply a 1 pixel GIF instead of {}

Invalid incoming images cause other things to fail in my pipeline and it would be nice if that could be caught earlier

@rpong
Copy link

rpong commented Jul 28, 2019

It would be great if one could provide a default fallback image URL in case the image processing is not able to handle the incoming image.

Or at least supply a 1 pixel GIF instead of {}

Invalid incoming images cause other things to fail in my pipeline and it would be nice if that could be caught earlier

Hi, might be unrelated, but were you able to check the error associated with {} returns? for us, it was because of VipsJpeg: Invalid SOS parameters for sequential JPEG (the image is valid, but was taken using a samsung cam/camera phone which inserts weird meta).

I pushed a PR which addresses this but it requires a node_modules rebuild as a more recent version of Sharp is needed. -> #130

@hayesry
Copy link
Member

hayesry commented Jul 30, 2019

Hey @mberneis - thanks for your feature request. I've gone ahead and added that to our backlog for the solution and will begin looking into it!

@rpong - sorry you've been having trouble using images from Samsung devices with this solution. I've made a note of this as well and will look into the PR you provided at #130. Thanks!

@rodrigofirpo
Copy link

Hi @hayesry

I was looking for something similiar to @mberneis request, but in my case was just to have a "default image" when a 404 is produced from the S3 (when the image does not exist in the S3 bucket).

Is there any way I can setup this (default image) without making any change in the Lamba code and/or the infrastructure?

Thanks a lot!

@hayesry
Copy link
Member

hayesry commented Aug 3, 2019

Hey @rodrigofirpo

For simply returning a default image whenever one can't be found in the S3 bucket, I would use the getOriginalImage() method at source/image-handler/image-request.js:42 as a starting point. My recommendation would be to replace the Promise.reject({}) content in the catch(err) block with something like:
catch(err) {
. return Promise.reject(defaultImageBuffer)
};
...where defaultImageBuffer is the default image (in Buffer form) you would like returned whenever an error is thrown from S3. Hope this helps!

@rodrigofirpo
Copy link

Thanks @hayesry,

We will go this way! If we see that our solution is clean (from the programming POV) and could be helpful for other users we will create a Pull Request, perhaps other users could take advantage from this.

Best!

@4ice
Copy link

4ice commented Dec 19, 2019

Hello, I also want to do the same as you described above @rodrigofirpo, with a fallback image. Have you made a working solution? Is it something that you could share?

@beomseoklee
Copy link
Member

Hi all,

If anyone is still interested in the default image fallback, what kind of fallback image would be good for everyone? Please let us know so that we can think about this one.

@rodrigofirpo
Copy link

@4ice sorry I didn't answer before. At the moment we have this functionality in stand-by (for other reasons)

However, even if @beomseoklee solution could help a lot of people (thanks for that), that is not our case, we need to set our company fallback image.

@bs-thomas
Copy link

Maybe we can make this fallback image a specifiable "parameter"?

@mberneis
Copy link
Author

mberneis commented Mar 5, 2020

Yes still interested in a solution / passing a default image url as an optional parameter would be great. If data url would be supported
a 1 pixel invisible gif would be easy to pass as well

@beomseoklee
Copy link
Member

Thanks for waiting. We've released v5.1.0, and the version contains the default fallback image feature so that you can define your own image to return when any error happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants