Request: Crop/pad image to aspect ratio

Older bugs which are supposed to be fixed in 0.84. *** Please try to reproduce your bug and confirm the bug fix. ***

Moderators: XnTriq, helmut, xnview, Dreamer

Danny
Posts: 575
Joined: Sat Sep 04, 2004 5:09 pm

Request: Crop/pad image to aspect ratio

Post 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/
User avatar
xnview
Author of XnView
Posts: 43607
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Request: Crop/pad image to aspect ratio

Post by xnview »

So a ratio & background color?
Pierre.
Danny
Posts: 575
Joined: Sat Sep 04, 2004 5:09 pm

Re: Request: Crop/pad image to aspect ratio

Post 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.
User avatar
xnview
Author of XnView
Posts: 43607
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Request: Crop/pad image to aspect ratio

Post by xnview »

See issue for current status and some details.
Pierre.
User avatar
xnview
Author of XnView
Posts: 43607
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Request: Crop/pad image to aspect ratio

Post by xnview »

This problem is supposed to be fixed in XnView MP 1.3.1. Please check and confirm the bug fix here.
Pierre.
cday
XnThusiast
Posts: 3985
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: ** English - English (=Master)

Post 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" ?
User avatar
helmut
Posts: 8705
Joined: Sun Oct 12, 2003 6:47 pm
Location: Frankfurt, Germany

Re: Request: Crop/pad image to aspect ratio

Post 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?
User avatar
helmut
Posts: 8705
Joined: Sun Oct 12, 2003 6:47 pm
Location: Frankfurt, Germany

Re: ** English - English (=Master)

Post 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"
User avatar
user0
XnThusiast
Posts: 1549
Joined: Sat May 09, 2015 9:37 am

del

Post by user0 »

del
Last edited by user0 on Wed Nov 30, 2022 3:11 am, edited 1 time in total.
User avatar
user0
XnThusiast
Posts: 1549
Joined: Sat May 09, 2015 9:37 am

Re: Request: Crop/pad image to aspect ratio

Post 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 :)
User avatar
xnview
Author of XnView
Posts: 43607
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Request: Crop/pad image to aspect ratio

Post by xnview »

user0 wrote: Tue Nov 29, 2022 2:53 pm btw, where can I check AspectPad in xnview?
in batch convert>actions
Pierre.
User avatar
user0
XnThusiast
Posts: 1549
Joined: Sat May 09, 2015 9:37 am

Re: Request: Crop/pad image to aspect ratio

Post 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
  • GIMP
    resize_canvas_gimp.png
You do not have the required permissions to view the files attached to this post.
cday
XnThusiast
Posts: 3985
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Request: Crop/pad image to aspect ratio

Post 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?
User avatar
user0
XnThusiast
Posts: 1549
Joined: Sat May 09, 2015 9:37 am

Re: Request: Crop/pad image to aspect ratio

Post by user0 »

quick mockup
- extend/crop mode is not that obvious though
You do not have the required permissions to view the files attached to this post.
User avatar
helmut
Posts: 8705
Joined: Sun Oct 12, 2003 6:47 pm
Location: Frankfurt, Germany

Re: Request: Crop/pad image to aspect ratio

Post 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.