-
Notifications
You must be signed in to change notification settings - Fork 4
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
Some thumbnail sizes not generated when using this plugin #3
Comments
Follow up: it looks like it's the usage of thumbnail in the _resize function that is problematic. If used, for the particular size I'm looking for, the next $resized->crop call gives this error: extract_area: bad extract area If I change your code to use resize in place of thumbnail then the crop works. |
Can you post a complete example of the code you are using and share an example image? i.e. how you are registering the image size. This way I'll be able to look into the issue. Thanks! |
If
But please do post the code and the image so I can fix the underlying issue 🙂 |
Hi @joppuyo and thanks for the great plugin. OK, so it happens when trying to get a 650x433px thumbnail of the attached image. This is a custom thumbnail size registered in my WP install by a theme I'm using: add_image_size('custome-thumb', 650, 9999); The _resize function of this plugin is called for each thumbnail size but it fails only on this particular one. More precisely, it fails with the extract_area: bad extract area error at the crop stage that happens in this function after the call to thumbnail_image has been made first. See attached debug session capture bellow. If I replace the call to thumbnail_image to a call to resize (by forcing the else part of the if in your function), then crop doesn't fail. This discussion continued in the other open issue (#1) with @jcupitt, who is suggesting that the problem lies with the fact that you compute the $scale ratio with 2 different methods. By running the code step by step for different images, I was not able to pinpoint exactly why in this particular case the extract area is "bad". A rounding issue maybe? |
Hey @joppuyo, my thought from a quick look at the code was that |
Upon further inspection, the error arrises because when called on this particular image with parameters width = 650 and height = 433, the thumbnail_image function return a 649x433 images. Thus, the following call to crop fails for out of bounds cause. So, it's indeed a rounding issue, but it looks that the issue is inside the thumbnail_image implementation itself. @jcupitt what do you think? |
I think it's the computation of Off-topic, but |
I don't think that's the problem in this particular case because The resulting call code is
|
Too dirty I think :( I would try to fix the underlying problem. |
OK. In any case, putting aside the supposed rounding issue in the code of @joppuyo , it doesn't change the fact that when calling Or is it expected behavior because 649x433 fits within 650 x 433 (as per the doc - https://libvips.github.io/libvips/API/current/libvips-resample.html#vips-thumbnail) ? Again, sorry for the dumb question ;) |
Ah I see, sorry. Yes, it's expected behaviour for Note that imagemagick has the same behaviour:
|
OK, then... for the time being, I guess that my solution of slightly breaking the image ratio for this edge case using the Maybe another solution is not to do a resize and then a crop but to use the crop option of Also, I won't change thumbnail_image to thumbnail because, reading from the other opened issue, it seems that there is some compatibility issue with wordpress when previous rotation or cropping are applied. |
Thanks for looking into it deeper. In my opinion, it's not so important what the underlying technical issue is, I think the most important thing is to fix this plugin so works correctly without throwing exceptions. WordPress image processing is pretty complex because you have resizing, cropping, rotation and flipping, and other operations. Also, WordPress image sizes can be fixed or proportional and they can have crop gravity. It's been a while since the last time I worked on this plugin it's going to take some time for me to get up to speed and also test all possible cases. In any case, I will try to match the functionality with ImageMagick and try to make sure there are no edge cases like this issue. I would love to use In my testing (by running this plugin via WordPress admin interface) |
Hi, thanks for writing this plugin. I have a huge performance improvement compared to ImageMagick. Unfortunately, when switching to VIPS on my production environment, I noticed that one particular size of thumbnail (650px x 433px - registered by the theme I'm using) is not generated from my pictures (which are admittedly quite big at 4000x2667). Bigger thumbnails are generated, but not this small one.
On my dev environment based on Homestead, it works though. Since the production and dev environment vary greatly (same php version though), my guess is that there is some kind of memory limit / timeout parameter at play. But I'm unable to find it. There is nothing in the php error logs.
How do you advise I debug this problem?
Thanks.
The text was updated successfully, but these errors were encountered: