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

Height of the image become 0 during the resizing #2653

Closed
jczapiewski-cksource opened this issue Apr 6, 2021 · 6 comments
Closed

Height of the image become 0 during the resizing #2653

jczapiewski-cksource opened this issue Apr 6, 2021 · 6 comments

Comments

@jczapiewski-cksource
Copy link

I'm trying to resize an image to given width without setting a height property for a 1px height image. Example image dimensions can be like 900px x 1px.

As a result, the following errors are thrown:

GLib-GObject-WARNING **: 12:34:55.444: value "nan" of type 'gdouble' is invalid or out of range for property 'vscale' of type 'gdouble'
GLib-GObject-WARNING **: 12:34:55.445: value "0" of type 'gint' is invalid or out of range for property 'height' of type 'gint'
embed: parameter height not set

The question is, is it possible to set a minimum dimension value to avoid cases like this (eg. setting the height to 1px when the processed image is smaller)? I've found a few threads suggesting using max and min but it seems to be no longer valid nor these things are not mentioned in the documentation. I know that I can calculate the dimensions based on the buffer but I'm wondering if it is possible to handle this somehow automatically.

Thanks in advance!

@lovell
Copy link
Owner

lovell commented Apr 6, 2021

There should be logic to prevent this, but it's possible there are still edge cases. Please can you provide complete, standalone code and a sample input image that allows someone else to reproduce this.

@jczapiewski-cksource
Copy link
Author

Thanks for the response. I've created a simple repository to reproduce the issue: https://github.com/jczapiewski-cksource/sharp-resize-issue. The sample code and the image are included.

@lovell
Copy link
Owner

lovell commented Apr 7, 2021

Thank you, I can reproduce this. It looks like a bug in the shrink-on-load handling that can affect very thin JPEG images where one dimension is 3 pixels or less - leave it with me.

@lovell lovell added bug and removed question labels Apr 7, 2021
@lovell lovell added this to the v0.28.2 milestone Apr 7, 2021
@lovell
Copy link
Owner

lovell commented Apr 7, 2021

Commit ed5d753 fixes this and adds a test case that was previously failing. Thank you for reporting!

@jczapiewski-cksource
Copy link
Author

Thank You!

@lovell
Copy link
Owner

lovell commented May 10, 2021

v0.28.2 now available with the fix for this.

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

2 participants