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

set maxWidth and/or maxHeight #305

Closed
astrowq opened this issue Dec 25, 2023 · 9 comments
Closed

set maxWidth and/or maxHeight #305

astrowq opened this issue Dec 25, 2023 · 9 comments
Assignees
Labels
question Further information is requested

Comments

@astrowq
Copy link

astrowq commented Dec 25, 2023

Is your feature request related to a problem? Please describe.

It would be useful in some cases to be able to set a maximum width or maximum height when converting a set of images. For example, I have a set of images where smaller ones are about 200×200px, but large ones are about 1000×1000px. It makes no sense to use the width or height request parameters. If setting width to be 500px, the smaller ones will be stretched and pixelized.

Describe the solution you'd like
Able to set maxWidth and/or maxHeight in the request parameter. When enabled and set, only images larger than the maxWidth or maxHeight will be resized.

@astrowq
Copy link
Author

astrowq commented Dec 25, 2023

A side note: the extra parameters of width and height do not seem to be always working when the values are greater than the original dimension.

e.g. for https://inspirehep.net/files/b5df560358b1bec3f11047cad9bb7bdd, when setting width to be 300px, it's enlarged properly; but not when the width is 600px.

@n0vad3v
Copy link
Member

n0vad3v commented Dec 26, 2023

Thanks for your feedback, I understand that there are two parts of information in this issue:

  1. A feature request that is similar to previous issue/pr: Variable Compression Size Depending on File Size #268 and ISSUE-268 Add min file size param to config #270
  2. Bug that for given example image https://inspirehep.net/files/b5df560358b1bec3f11047cad9bb7bdd, if width set to 600px, the image is not enlarged.

To clarify my understanding on the first one, if there are configs called maxWidth and maxHeight set to 500(px), then for a request with get params: some-image.jpg?width=600

A small image with 400x400px will not be stretched to 600x600px
A larger image with 1200x1200px will be resized to 500x500px
A image with 550x550px will be stretched to 600x600px

Did I grasp this correctly?

@astrowq
Copy link
Author

astrowq commented Dec 26, 2023

Not really the same as the issue 268 where they are talking about final file size. I am interested in the dimensions of the converted images, i.e. width and height.

For your example, the maxWidth and maxHeight are supposed to be a hard limit, so a image with 550×550px will be scaled down to 500×500px too, as far as I would like it to be.

@astrowq
Copy link
Author

astrowq commented Dec 26, 2023

For the side note, I will test on more images. If it persists, I can open another issue.

@BennyThink BennyThink added the question Further information is requested label Dec 27, 2023
@n0vad3v
Copy link
Member

n0vad3v commented Jan 4, 2024

For the side note, I will test on more images. If it persists, I can open another issue.

Do you have any update on this issue?

so a image with 550×550px will be scaled down to 500×500px too,

Sorry I've missed request parameter. in your issue content, so this feature is to ensure that all images should below the given dimension, so given it's a "request parameter.", assume some requests are made to: /path/image_<id>.jpg?max_width=500&max_height=500, then

  1. image_1.jpg with 400x400px will not be resized and will be rendered in 400x400px
  2. image_2.jpg with 600x600px will be resized to 500x500px
  3. image_3.jpg with 400x1000px will be resized to 200x500px
  4. image_4.jpg with 1000x1000px will be resized to 500x500px

Am I getting it right?

@astrowq
Copy link
Author

astrowq commented Jan 4, 2024

Yes, you are right!

Unfortunately, the issue appears for some images but works fine for others. I can't really find any pattern. I will open an issue when I find time to do it.

Also, there was another weird problem when I tried to migrate to a new server: it stops for no reason and restarts. I will report it later!

@n0vad3v
Copy link
Member

n0vad3v commented Mar 11, 2024

@astrowq We're planning to include this feature in our next major version, draft PR #321

BTW, is there any update on theses two issues:

  1. "the issue appears for some images but works fine for others. I can't really find any pattern. I will open an issue when I find time to do it."
  2. "there was another weird problem when I tried to migrate to a new server: it stops for no reason and restarts. I will report it later!"

@astrowq
Copy link
Author

astrowq commented Mar 14, 2024

Many thanks for the work!

Regarding the two possible issues, I haven't got time to investigate them
But will report if they appear again and persist.

@n0vad3v
Copy link
Member

n0vad3v commented Mar 22, 2024

@astrowq We've released 0.11.0 https://github.com/webp-sh/webp_server_go/releases/tag/0.11.0, please check it out! 😃

@n0vad3v n0vad3v closed this as completed Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants