Page 1 of 2

Request: Crop/pad image to aspect ratio

Posted: Mon Apr 01, 2019 6:02 pm
by Danny
Let's say we have a bunch of images with varying dimensions (w×h) and I want them all to fit into a 16:9 canvas, but I don't want to define a fixed size (like 1920×1080px). The wider side should stay the same, only the narrow side of the image should be padded with a given color or transparency until the desired aspect ration is met.

It seem like there's currently no way to achieve that, so I'm asking for a solution.

Related: https://newsgroup.xnview.com/viewtopic.php?f=79&t=38104

Basically what this script does: http://www.fmwconcepts.com/imagemagick/aspectpad/

Re: Request: Crop/pad image to aspect ratio

Posted: Mon Apr 15, 2019 2:18 pm
by xnview
So a ratio & background color?

Re: Request: Crop/pad image to aspect ratio

Posted: Sun Oct 02, 2022 2:28 pm
by Danny
xnview wrote: Mon Apr 15, 2019 2:18 pm So a ratio & background color?
In other words, yes. Don't scale the image content, just adjust the canvas size and fill the padded area outside with a color.

Sorry, I don't come here as often as I used to.

Re: Request: Crop/pad image to aspect ratio

Posted: Mon Oct 10, 2022 3:00 pm
by xnview
See issue for current status and some details.

Re: Request: Crop/pad image to aspect ratio

Posted: Thu Oct 13, 2022 2:33 pm
by xnview
This problem is supposed to be fixed in XnView MP 1.3.1. Please check and confirm the bug fix here.

Re: ** English - English (=Master)

Posted: Mon Nov 28, 2022 9:47 pm
by cday
<Moderator's note: This post has been split from another topic>

AspectPad ??

I don't recognise this as a standard English term, a quick search seems to show it to be the name of one of the scripts in "Fred's ImageMagick Scripts" collection, possibly nothing more.

While I don't immediately understand the action performed, perhaps it could be represented by a general term based on "Fit" ?

Re: Request: Crop/pad image to aspect ratio

Posted: Tue Nov 29, 2022 10:03 am
by helmut
Always good if new features make it into XnView. Basically, this new feature allows for resizing canvas of an image to a specific ratio is added.

ATM, this feature...
...is implemented in XnView as "AspectPad".
...is a completely new, stand-alone conversion.

"AspectPad" is difficult to understand and almost impossible to translate to other languaes. This would be a new, exotic terminology in XnView which makes things complicated. No good.
I wonder whether this little functionality could be included into XnView in a more intuitive way. Already, there is "Canvas resize" which allows for resizing the canvas of an image while not resizing the image itself. As original poster pointed out "Canvas resize" doesn't allow for resizing to a specific ratio. So I'd suggest: Add an option "Ratio" to "Canvas resize" which can be choosen as an alternative to "Size" and then we're done. A simple and intuitive solution without re-inventing the wheel.

What do other people think?

Re: ** English - English (=Master)

Posted: Tue Nov 29, 2022 10:26 am
by helmut
cday wrote: Mon Nov 28, 2022 9:47 pm AspectPad ??

I don't recognise this as a standard English term, a quick search seems to show it to be the name of one of the scripts in "Fred's ImageMagick Scripts" collection, possibly nothing more.

While I don't immediately understand the action performed, perhaps it could be represented by a general term based on "Fit" ?
"AspectPad" is indeed pretty weird. I've started a discussion in topic "Request: Crop/pad image to aspect ratio"

del

Posted: Tue Nov 29, 2022 2:47 pm
by user0
del

Re: Request: Crop/pad image to aspect ratio

Posted: Tue Nov 29, 2022 2:53 pm
by user0
Canvas resize dialog is the perfect place for this functionality.

btw, where can I check AspectPad in xnview?

ps. I will add some pictures from other software, just for reference. Since I already have them :)

Re: Request: Crop/pad image to aspect ratio

Posted: Tue Nov 29, 2022 3:01 pm
by xnview
user0 wrote: Tue Nov 29, 2022 2:53 pm btw, where can I check AspectPad in xnview?
in batch convert>actions

Re: Request: Crop/pad image to aspect ratio

Posted: Tue Nov 29, 2022 3:26 pm
by user0
xnview wrote: Tue Nov 29, 2022 3:01 pm in batch convert>actions
got it, thanks.
aspect_pad.png
Yeah, I definetly would expect this feature in 'Canvas resize' not as standalong one
As far as I understand it only adds canvas space, never crop, so I suggest to add something like "crop/add" selector (maybe use anchor point to define where to crop more).
Also entering values in number x number format is slightly more convinient than just a single nimber, e.g. 16:9 easier to use than 1.78 imho (or use both, like in Irfanview).

Some examples:
1. have ratio in Canvas resize dialog
  • ACDSee
    resize_canvas_acdsee.png
  • Irfanview
    resize_canvas_infa_ratio.png
2. do not have ratio in Canvas resize dialog
  • FastStone
    resize_canvas_FastStone.png
  • Photoshop
    resize_canvas_ps.png
    resize_canvas_ps.png (25.78 KiB) Viewed 4151 times
  • GIMP
    resize_canvas_gimp.png

Re: Request: Crop/pad image to aspect ratio

Posted: Tue Nov 29, 2022 4:38 pm
by cday
Within the present Canvas resize menu design, a new option Mode -- Fit ratio could describe the new function if new canvas, with the set Background colour, is added as required?

But would that be compatible with the rest of the menu?

Re: Request: Crop/pad image to aspect ratio

Posted: Tue Nov 29, 2022 5:16 pm
by user0
quick mockup
- extend/crop mode is not that obvious though

Re: Request: Crop/pad image to aspect ratio

Posted: Tue Nov 29, 2022 9:11 pm
by helmut
Thank you, user0 and cday for your replies. Good to see various examples handling the same issue and even mockups.

From your feedback I read that adding "Ratio" or "Aspect ratio" in "Canvas resize" makes sense. I just had a look at "Canvas resize" in batch conversion and noticed that in batch conversion there's a mode available (Normal, Square - longest side, Square - Shortest side) available which aren't available in normal "Canvas resize". Again, that's no good.

From what I can see for canvas resize three modes are needed:
  • Absolute size (= resize canvas to specified width & height [pixel or percent])
  • Relative size (= increase canvas width & height by specified number of pixels or percent)
  • Aspect ratio (= resize canvas to a specific aspect ratio)
Depending on chosen mode additional settings are available.

Please note that "Canvas resize" and "Cropping" are related actions which should be kept separate to keep dialogs simple.