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

Fail gracefully when format=auto #309

Open
mrkurt opened this issue May 27, 2020 · 8 comments
Open

Fail gracefully when format=auto #309

mrkurt opened this issue May 27, 2020 · 8 comments
Assignees

Comments

@mrkurt
Copy link

mrkurt commented May 27, 2020

We're seeing images that fail on webp encoding, but work fine with just jpg. The actual issue is #270.

Is it possible to make imaginary fail gracefully and just return the jpeg data it has when this kind of error happens?

@h2non h2non self-assigned this May 28, 2020
h2non added a commit that referenced this issue Jun 7, 2020
h2non added a commit that referenced this issue Jun 7, 2020
* feat: add fly.io

* feat(readme): fly image width

* feat(readme): add html image + badge

* fix(docs): try space non-URL encoding

* Update README.md

* Update README.md

* Update README.md

* feat(docs): add fly.io info and links

* feat(#305, #309, #308, #305. #284)

* fix(ci): golinter

* fix(Dockerfile): use root folder for go test / ci linter

* fix(ci): allow to fail  go 1.14 build, still not sure why

* fix(ci): bad yaml format

* fix(ci): use travis-compatible regex

* fix(ci): lets skip go1.14 for now

* fix(mod): update dependencies
@h2non
Copy link
Owner

h2non commented Jun 7, 2020

#270 is fixed in v1.2.0, which uses bimg v1.1.0, by fallback to a default ICC profile if no one is specified.

I will keep this issue open since it is still room for future improvement in the API behavior about the underlying idea of smarter format detection mechanism by inferring accepted image using Client Hints HTTP headers.

@h2non
Copy link
Owner

h2non commented Jun 7, 2020

Related feature proposal: #253

@n1bs
Copy link

n1bs commented Jul 28, 2020

Hello,

We seems facing same kind of problem. When trying to convert JPEG (160px x 21600px) into WebP - getting HTTP400 with this inside:
{"message":"Error while processing the image: vips2webp: unable to encode","status":400}

Would be great to fallback into JPEG in such cases instead of error.

In our case we send requests with explicit type=webp in query string.

@h2non
Copy link
Owner

h2non commented Jul 28, 2020

Hello @n1bs!
Can you provide some WebP image that is giving you trouble so I can reproduce? I assume you are running the v1.2.2.

A fallback mechanism might be optimal in this case, but I'd rather prefer this behavior to be explicitly requested in the HTTP request contract.

Something like overloading the current type query param to host multiple allowed formats with order preference could work nicely here: type=webp,jpeg.

Would that work?

@mrkurt
Copy link
Author

mrkurt commented Jul 28, 2020

I managed to replicate this with a random jpeg: https://i.imgur.com/6gBwEjy.jpg

The imaginary params were: /convert?url=https://i.imgur.com/6gBwEjy.jpg&stripmeta=true&type=webp&quality=80

Type with multiple available formats would work great for me.

@n1bs
Copy link

n1bs commented Jul 29, 2020

thanks for the test image, Kurt!

@h2non thanks for the quick look into this! Just to confirm - we're running v1.2.2 and type=webp,jpeg would work great for us.

@h2non
Copy link
Owner

h2non commented Jul 29, 2020

Cool, I will try to ship this feature by the end of the week or early next week. Will keep things posted here!

@h2non
Copy link
Owner

h2non commented Aug 4, 2020

A fix was pushed in v1.2.3 under Docker image tags latest, 1, and 1.2.3.

There is no change required in terms of URL API consumption.
In case the image encoding fails, it will transparently fall back to JPEG encoding.

You can test it with:
/convert?url=https://i.imgur.com/6gBwEjy.jpg&stripmeta=true&type=webp&quality=80

j-keck pushed a commit to artidis/imaginary that referenced this issue Aug 11, 2022
* feat: add fly.io

* feat(readme): fly image width

* feat(readme): add html image + badge

* fix(docs): try space non-URL encoding

* Update README.md

* Update README.md

* Update README.md

* feat(docs): add fly.io info and links

* feat(h2non#305, h2non#309, h2non#308, h2non#305. h2non#284)

* fix(ci): golinter

* fix(Dockerfile): use root folder for go test / ci linter

* fix(ci): allow to fail  go 1.14 build, still not sure why

* fix(ci): bad yaml format

* fix(ci): use travis-compatible regex

* fix(ci): lets skip go1.14 for now

* fix(mod): update dependencies
j-keck pushed a commit to artidis/imaginary that referenced this issue Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants