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

vips_thumbnail fails when the target dimensions are bigger than the original, it is supposed to crop and only downsize #2157

Closed
Andrewsville opened this issue Mar 21, 2021 · 5 comments
Labels

Comments

@Andrewsville
Copy link

Bug report

vips_thubmnail fails under specific circumstances with a not very clear error message smartcrop: bad extract area:

  1. The input image has one or both dimensions smaller than the thumbnail.
  2. crop != VIPS_INTERESTING_NONE meaning the image should be cropped to fill the whole thumbnail.
  3. size == VIPS_SIZE_DOWN meaning the original image should only be downscaled, if necessary.

To Reproduce

  1. Have an image, for example 300 x 300 px.
  2. vips thumbnail original.jpeg thumb.jpg 400 --height 200 --size down --crop entropy
  3. See the error smartcrop: bad extract area

Expected behavior

This combination of parameters and input image obviously means that vips_thubmnail cannot (completely) do what it is asked to - the image is not big enough to fill the thumbnail dimensions and vips cannot upscale it. This means that there are IMO two solutions:

  1. Be strict and return an error but explain what is wrong (the image is too small and cannot be upscaled).
  2. Do what's possible and generate a thumbnail with at lest one dimension smaller than the requested thumbnail size.

Actual behavior

vips_thubmnail fails with a not very clear error message smartcrop: bad extract area probably because it calculates coordinates out of the image bounds.

A simple workaround for the moment is to set the thumbnail dimensions to min(original_dimension, requested_dimension) making it do the suggested solution 2 from above.

Environment

Ubuntu Groovy with distribution vips:

andrew@andrew-x1:~$ vips -v
vips-8.10.2-Tue Oct 13 14:56:17 UTC 2020

as well as compiled from the latest 8.10.6-beta2 relase:

andrew@andrew-x1:/$ vips -v
vips-8.10.6-Mon Mar  8 15:23:31 UTC 2021
jcupitt added a commit that referenced this issue Jul 18, 2021
thumbnail could fail for small images if upsize was disallowed and crop
was enabled, thanks Andrewsville

see #2157
@jcupitt
Copy link
Member

jcupitt commented Jul 18, 2021

Hi @Andrewsville, ooops, I'm so sorry, this dropped off my todo list.

I've fixed this in master so it does your 2. above and this improvement should be in 8.12. Thank you very much for the idea!

@jcupitt jcupitt closed this as completed Jul 18, 2021
@andrews05
Copy link

andrews05 commented Oct 6, 2021

Just encountered this myself, so thanks for the fix! Do you have a rough idea of when to expect 8.12?

[edit] So in my case I actually had this problem with a pdf. It seems vips (or poppler) is loading the pdf at a relatively low DPI and has decided that its "size" is smaller than the thumbnail I requested and then fails, which doesn't really make sense.
Specifically, my pdf is 15cm wide and loading this in vips shows a width of 425, which equates to 72 dpi. Could this be increased to 150 perhaps?

@jcupitt
Copy link
Member

jcupitt commented Oct 6, 2021

8.12 should be fairly soon now. We're still tinkering with a new GIF saver, but when that's done it should be ready.

@andrews05
Copy link

Cool, thanks. Should I make a new issue regarding the pdf dpi?

@jcupitt
Copy link
Member

jcupitt commented Oct 6, 2021

Sure! If you have a sample image and way to make vipsthumbnail misbehave, we'd love to see it.

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

No branches or pull requests

3 participants