Issue 561 in webp: cwebp resize stretching image, provide option to fill instead

413 views
Skip to first unread message

goewe… via monorail

unread,
Mar 10, 2022, 1:00:52 PM3/10/22
to webp-d...@webmproject.org
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 561 by goewe...@gmail.com: cwebp resize stretching image, provide option to fill instead
https://bugs.chromium.org/p/webp/issues/detail?id=561

What steps will reproduce the problem?
1. download https://upload.wikimedia.org/wikipedia/commons/3/39/Lichtenstein_img_processing_test.png
2. cwebp -resize 540 360 "Lichtenstein_img_processing_test.png" -o "Lichtenstein_img_processing_test.webp"
3. compare images for stretching

What is the expected output? What do you see instead?
Expected to resize but not stretch the image.
But image does indeed stretch.


What version of the product are you using? On what operating system?
v1.2.2
Windows 10


Please provide any additional information below.

Is it possible to provide a way to resize images using a fill method?

Attachments:
Lichtenstein_img_processing_test.png 347 KB
Lichtenstein_img_processing_test.webp 17.2 KB

--
You received this message because:
1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

goewe… via monorail

unread,
Mar 10, 2022, 1:05:23 PM3/10/22
to webp-d...@webmproject.org

Comment #1 on issue 561 by goewe...@gmail.com: cwebp resize stretching image, provide option to fill instead
https://bugs.chromium.org/p/webp/issues/detail?id=561#c1

Example of what I mean by fill.

Attachments:
Lichtenstein_img_processing_test_fill_400x500.png 298 KB

jz… via monorail

unread,
Mar 10, 2022, 3:25:40 PM3/10/22
to webp-d...@webmproject.org

Comment #2 on issue 561 by jz...@google.com: cwebp resize stretching image, provide option to fill instead
https://bugs.chromium.org/p/webp/issues/detail?id=561#c2

If you'd like to preserve the aspect ratio when resizing you can set one dimension to 0 [1]. Try -resize 540 0 in the above example.

[1] https://developers.google.com/speed/webp/docs/cwebp#options

goewe… via monorail

unread,
Mar 16, 2022, 10:45:57 AM3/16/22
to webp-d...@webmproject.org

Comment #4 on issue 561 by goewe...@gmail.com: cwebp resize stretching image, provide option to fill instead
https://bugs.chromium.org/p/webp/issues/detail?id=561#c4

Yes, I know that you can preserve the aspect ratio using only one dimension. What I was asking about was setting both dimensions, a new aspect ratio, but allowing the image to preserve the content instead of stretch.

It seems like this would be similar to cropping. But a fill resize actually scales the image proportionally and crops as needed. Not sure how you would do this with the current settings. Maybe resize, keeping the aspect ratio, before cropping?

Here are more examples.

Attachments:
Lichtenstein_img_processing_test_fill_150x300.png 79.7 KB
Lichtenstein_img_processing_test_crop_150x300.webp 6.2 KB

jz… via monorail

unread,
Mar 16, 2022, 3:27:36 PM3/16/22
to webp-d...@webmproject.org

Comment #5 on issue 561 by jz...@google.com: cwebp resize stretching image, provide option to fill instead
https://bugs.chromium.org/p/webp/issues/detail?id=561#c5

Thanks for the additional examples. Those look like resized cropped versions. With cwebp resize is applied after cropping. There's no option to do a fill, and just to check, by fill I mean letterbox, as in [1].

[1] https://docs.imgix.com/apis/rendering/size/fit#fill

pasca… via monorail

unread,
Mar 16, 2022, 5:57:50 PM3/16/22
to webp-d...@webmproject.org

Comment #6 on issue 561 by pasca...@gmail.com: cwebp resize stretching image, provide option to fill instead
https://bugs.chromium.org/p/webp/issues/detail?id=561#c6

Maybe using Imagemagick for these manipulations is a viable option for you:

https://legacy.imagemagick.org/Usage/thumbnails/#fit_summery

Changing the resize/crop order within libwebp is a difficult task...

goewe… via monorail

unread,
Mar 17, 2022, 11:00:39 AM3/17/22
to webp-d...@webmproject.org

Comment #7 on issue 561 by goewe...@gmail.com: cwebp resize stretching image, provide option to fill instead
https://bugs.chromium.org/p/webp/issues/detail?id=561#c7

If it's difficult then don't worry about it. Previously I was just using the Windows PowerToys Resize tool before converting to webp. And that works sufficiently for now.

Thanks for all the feedback.

Git Watcher via monorail

unread,
Mar 18, 2022, 2:26:04 AM3/18/22
to webp-d...@webmproject.org

Comment #8 on issue 561 by Git Watcher: cwebp resize stretching image, provide option to fill instead
https://bugs.chromium.org/p/webp/issues/detail?id=561#c8

The following revision refers to this bug:
https://chromium.googlesource.com/webm/libwebp/+/34bb332ca15d9ce605280265c6b042cef149f68d

commit 34bb332ca15d9ce605280265c6b042cef149f68d
Author: James Zern <jz...@google.com>
Date: Thu Mar 17 17:29:02 2022

man/cwebp.1: add note about crop/resize order

+ normalize help text in [cd]webp

Bug: webp:561
Change-Id: Id92ec4228d4933cd033b2bf68a43192532cef483

[modify] https://crrev.com/34bb332ca15d9ce605280265c6b042cef149f68d/doc/tools.md
[modify] https://crrev.com/34bb332ca15d9ce605280265c6b042cef149f68d/examples/dwebp.c
[modify] https://crrev.com/34bb332ca15d9ce605280265c6b042cef149f68d/man/cwebp.1
[modify] https://crrev.com/34bb332ca15d9ce605280265c6b042cef149f68d/examples/cwebp.c

pasca… via monorail

unread,
Mar 18, 2022, 2:28:52 AM3/18/22
to webp-d...@webmproject.org
Updates:
Owner: jz...@google.com
Status: Fixed

Comment #9 on issue 561 by pasca...@gmail.com: cwebp resize stretching image, provide option to fill instead
https://bugs.chromium.org/p/webp/issues/detail?id=561#c9

(No comment was entered for this change.)
Reply all
Reply to author
Forward
0 new messages