Transform ?

XnConvert Multi Platform - Windows, MacOSX, Linux
Post Reply
philippetev
Posts: 5
Joined: Thu Jan 02, 2014 2:07 pm

Transform ?

Post by philippetev » Thu Jan 02, 2014 2:12 pm

Is it possible to be resized an image (no matter the aspect ratio and the method) with keeping the original canvas size at the same time, much like the Transform option in Photoshop and other programs?

User avatar
xnview
Author of XnView
Posts: 31607
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Transform ?

Post by xnview » Thu Jan 02, 2014 4:41 pm

could you post an example?
Pierre.

philippetev
Posts: 5
Joined: Thu Jan 02, 2014 2:07 pm

Re: Transform ?

Post by philippetev » Thu Jan 02, 2014 6:33 pm

Well, the only example that comes to me in mind is my recent work: resizing icons (pure png images) to look better on 4:3 resolutions, displayed on 16:9 display (the BIOS VESA resolution). For that purpose, the pictures should be "squashed" by their width and height with a percentage, calculated by a formula and even if they look like an eggs on the native resolution, they look correctly on the BIOS resolution (1024x768), displayed on the wide screen (1366x768). Currently I'm using PixelMator and its Transform option. I select it, set the width to let's say 75% without keeping the proportions (so it's 100% height and 75% width) and when I press Apply, the image is being "squashed" but the canvas size doesn't change (which is the point because the icons images should be squares) and an ordinary resize would squash the canvas as well. Unfortunately, PixelMator doesn't have batch transformation capabilities.

User avatar
xnview
Author of XnView
Posts: 31607
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Transform ?

Post by xnview » Fri Jan 03, 2014 12:50 am

could you post an original image and the result?
Pierre.

philippetev
Posts: 5
Joined: Thu Jan 02, 2014 2:07 pm

Re: Transform ?

Post by philippetev » Fri Jan 03, 2014 10:16 pm

This is the original:

Image

and this is the result, width/height 75%/100%

Image

Both the original and the result have canvas size of 128x128 (with transparent background).

I've managed to accomplish similar effect, applying Resize, set to width 75% and height 100% and Canvas Size, set to Width 134% and Height 100%, but the Canvas Size width is different for the different picture sizes, which force me to try several combinations before the actual process.

cday
XnThusiast
Posts: 2138
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Transform ?

Post by cday » Fri Jan 03, 2014 10:48 pm

At a quick look I think so:
Image_1.png
lqFT3Tp-transformed.png
lqFT3Tp-transformed.png (9.61 KiB) Viewed 3032 times
You had better check carefully.

Edit:

I don't know why there's a black line around the image -- it's not shown in the screenshot 'After' display?

So maybe almost, or can that be fixed??

User avatar
XnTriq
Moderator & Librarian
Posts: 5434
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Transform ?

Post by XnTriq » Fri Jan 03, 2014 11:15 pm

cday wrote:I don't know why there's a black line around the image -- it's not shown in the screenshot 'After' display?
<!--// EDIT //

// EDIT //-->

cday
XnThusiast
Posts: 2138
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Transform ?

Post by cday » Fri Jan 03, 2014 11:26 pm

Thanks, I just opened the image in an image editor as an afterthought to check that and found that! But why is there a black border on the image I uploaded and not on the example images that were uploaded originally -- both viewed with the same forum settings?

*Note on the XnConvert settings in the screenshot above: some of the detailed settings such as the resampling method used may not be optimal.*

philippetev
Posts: 5
Joined: Thu Jan 02, 2014 2:07 pm

Re: Transform ?

Post by philippetev » Sat Jan 04, 2014 1:14 am

cday wrote:At a quick look I think so:
Image_1.png
lqFT3Tp-transformed.png
You had better check carefully.

Edit:

I don't know why there's a black line around the image -- it's not shown in the screenshot 'After' display?

So maybe almost, or can that be fixed??
Yes, that would work for this size, but imagine if you have several files with several sizes (ex. 128x128, 256x256 and 512x512) and want to convert all of them in one step? My solution is more generic, because it would work for (almost) all files in the batch, regarding their sizes, but it works only for square pictures and the point is to change the content without changing the background (canvas size), so the program can transform as many files in batch as possible, regarding their size and form (square or rectangle).

cday
XnThusiast
Posts: 2138
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Transform ?

Post by cday » Sat Jan 04, 2014 5:59 pm

philippetev wrote: ... imagine if you have several files with several sizes (ex. 128x128, 256x256 and 512x512) and want to convert all of them in one step
A modification then, but I'm not sure that it quite meets your needs:
Image_2.png
In the second action 'Canvas resize' rescaling the width and the height using percentages would ideally extend the process to the pixel dimensions you quote, or to any other dimensions. But there is a problem: rounding errors in the calculations sometimes result in pixel dimension very slightly different from the nominal rescaled value.

128x128 --> 127x128
256x256 --> 255x256
512x512 --> 511x512

I tried changing the width by 126% rather than 125%, for example, but that didn't produce a general solution for varying initial image sizes as the required correction changes with the image size. It isn't possible to enter decimal values.

If the transformed pixel dimensions must be *exactly* nominal then I don't see a way of obtaining that using XnConvert.

philippetev
Posts: 5
Joined: Thu Jan 02, 2014 2:07 pm

Re: Transform ?

Post by philippetev » Sun Jan 05, 2014 2:28 am

cday wrote:
philippetev wrote: ... imagine if you have several files with several sizes (ex. 128x128, 256x256 and 512x512) and want to convert all of them in one step
A modification then, but I'm not sure that it quite meets your needs:
Image_2.png
In the second action 'Canvas resize' rescaling the width and the height using percentages would ideally extend the process to the pixel dimensions you quote, or to any other dimensions. But there is a problem: rounding errors in the calculations sometimes result in pixel dimension very slightly different from the nominal rescaled value.

128x128 --> 127x128
256x256 --> 255x256
512x512 --> 511x512

I tried changing the width by 126% rather than 125%, for example, but that didn't produce a general solution for varying initial image sizes as the required correction changes with the image size. It isn't possible to enter decimal values.

If the transformed pixel dimensions must be *exactly* nominal then I don't see a way of obtaining that using XnConvert.
That was exactly my point, the Canvas percentage should be determined with trials/errors every time and the technique is completely useless for non-square pictures (ex. 168x140).

cday
XnThusiast
Posts: 2138
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Transform ?

Post by cday » Sun Jan 05, 2014 10:57 am

philippetev wrote: ... the Canvas percentage [needs to be] determined with trials/errors every time ...
The first method worked exactly with the image you uploaded, and the second method would work exactly for any image dimensions if the width calculations were more precise, but no, if you need the transformed image to have identical pixel dimensions neither method is usable at present.
philippetev wrote: the technique is completely useless for non-square pictures (ex. 168x140).
A similar rescaling technique could also be used for the image height, but whether that would meet your needs if the calculations were more precise I don't know.

The fact that applying a percentage change to the image canvas dimensions and then in a subsequent Action applying the inverse percentage change doesn't always restore the exact canvas dimension might be viewed as a bug, and could probably in principle be corrected.

User avatar
xnview
Author of XnView
Posts: 31607
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Transform ?

Post by xnview » Wed Mar 05, 2014 2:53 pm

Bug confirmed and will be fixed. See issue Issue 188 for current status and details.
Pierre.

Post Reply