How to crop from centre and then resize in one action?

XnConvert Multi Platform - Windows, MacOSX, Linux

Moderators: XnTriq, helmut, xnview

Post Reply
taksina
Posts: 8
Joined: Sat May 30, 2009 7:21 am

How to crop from centre and then resize in one action?

Post by taksina »

Can anybody guide me on how to crop a bunch of images from the centre and then resize to a specific size? Also is it possible to resize an image to 5 different sizes and rename each output image differently in a single action?
cday
XnThusiast
Posts: 3976
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: How to crop from centre and then resize in one action?

Post by cday »

taksina wrote:Can anybody guide me on how to crop a bunch of images from the centre and then resize to a specific size?
Resize.png
You should be able to do that using the 'Image > Canvas resize' action: you may need to experiment to find the most suitable 'Keep ratio' and 'Follow orientation' settings.
Also is it possible to resize an image to 5 different sizes and rename each output image differently in a single action?
No, it is only possible to output one image for each input file. You would have to run XnConvert five times with different settings, but it is possible to save the settings used when XnConvert is run as a script which can be reloaded later, so you could have five different scripts.

It should be possible to produce five different sized images with different file names directly using the command line utility NConvert, by creating a batch file that runs NConvert five times with different settings. But writing the script required if you are not used to using the command line would be rather more complex than using XnConvert. :)
Last edited by cday on Sat Jul 05, 2014 12:23 pm, edited 1 time in total.
taksina
Posts: 8
Joined: Sat May 30, 2009 7:21 am

Re: How to crop from centre and then resize in one action?

Post by taksina »

Thank you so much cday. I'll try that and will let you know.
cday
XnThusiast
Posts: 3976
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: How to crop from centre and then resize in one action?

Post by cday »

Thinking about your post again...

I think you need to follow the 'Canvas resize' action which should perform the crop you requested, with a 'Resize' action to produce the thumbnail dimensions you require for each of the five sizes...

Maybe you've already realised that? :)
taksina
Posts: 8
Joined: Sat May 30, 2009 7:21 am

Re: How to crop from centre and then resize in one action?

Post by taksina »

I've tried the resize method and it works fine for photos with same orientation as the target size, which helps a lot. But there are some with different orientation like shown in the attachments here. Is there a way to do that? My goal is to resize/crop some photos to the target size (specifically 63x82 pixels) regardless of the orientation of the original. It's okay to lose details so long as the object in the centre is kept.

Thanks for your great help.
This is the original file, full size.
This is the original file, full size.
This is the result I'm trying to achieve.
This is the result I'm trying to achieve.
After.jpg (17.3 KiB) Viewed 5418 times
cday
XnThusiast
Posts: 3976
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: How to crop from centre and then resize in one action?

Post by cday »

I'm slightly confused but could you try the following settings and let me know if they produce the result you want for landscape images like the one you posted:
Resize_2.png
The first action crops the input image about the center to the pixel height of the 'Before' image and a width calculated from the pixel width of the 'Before' image and the 63/82 width/height ratio of the thumbnail you want.

The second action rescales the cropped image to the thumbnail dimensions you want -- you might try different resampling methods to see if there is any difference in quality.

My output JPG file has a noticably smaller file size than yours but I don't see any very obvious difference in quality -- you can experiment with the JPG save settings on the Output tab. My output image is also very slightly displaced from yours, probably because it is cropped from the exact input image center, whereas you probably cropped by eye.

Note that I haven't considered whether it is possible to use the same settings for both landscape and portrait images, but if the above settings are useful you could try experimenting a bit with the 'Follow orientation' setting and see if you can solve that one. If not, and I don't have experience of that myself, could you post portrait and landscape Before and desired thumnail test images.
taksina
Posts: 8
Joined: Sat May 30, 2009 7:21 am

Re: How to crop from centre and then resize in one action?

Post by taksina »

Dear cday,

Thanks for your advice. I have great success with most of my pictures with the canvas size of 1600 x 2050 pixels. At least I understand the steps to go about it. Thanks a lot for your kind help. I'm no expert on image and XN tools and boards rock! :D

Have a nice day,

Taksina
Post Reply