Multiple resize (or other actions) per input

XnConvert Multi Platform - Windows, MacOSX, Linux

Moderators: helmut, XnTriq, xnview

Chamelia722
Posts: 2
Joined: Mon Dec 13, 2021 5:01 pm

Multiple resize (or other actions) per input

Post by Chamelia722 »

Hi there!

Thank you for this tool, I just started fiddling with it, and it seems nice :)

For my needs, I would like to create multiple sizes of the same picture of my photo album. For this, I am using multiple commands of "resize -ratio".
(FWIW I am using the Windows x64 version)

But this is clearly unoptimized, as it will load the source image (which is BIG, like 5MB) every time, which means 5 events (as I have 6 thumbnails) of useless loading of this huge file, resulting in like 2 seconds of computation to create these thumbnails whereas I guess it would take 500ms if the source image was to be only loaded once.

I could configure my phone to take lower-res photos, but it bothers me, because I prefer to have the best possible quality for my source photos.

It would be way more optimized/fast to load the image once, and then execute multiple actions on it.

For me it would be multiple resizes of different sizes, but one could think of so many use cases, like crop then resize then black and white then... For example I could be wanting to create a sepia version of the source photo to create a "old timer" album of sorts.

I don't quite mind if it's not there, because I don't have such "speed" requirements, but I still think it would make a great addition to the tool!

Is it planned to add such a feature?

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

Re: Multiple resize (or actions) per input

Post by cday »

Chamelia722 wrote: Mon Dec 13, 2021 5:14 pm I would like to create multiple sizes of the same picture of my photo album. For this, I am using multiple commands of "resize -ratio".

But this is clearly unoptimized, as it will load the source image (which is BIG, like 5MB) every time
In case there is any confusion, actions are performed successively, so for example a second resize action will be performed on the image resulting from the first resize.

Currently, in order to output alternative versions of a source image, it is necessary to run XnConvert once for each version.

Being able to output different versions of a source image from a single XnConvert run has been long recognised as useful, but so far has not implemented in part due to the need to define a suitable interface. A common use case is the need to output different size image versions for web use.

The command line utility NConvert may, however, be used to create multiple versions of an image or images, by placing multiple code lines in a batch file which could be run with a single click, although as far as I know it would still be necessary to load each source image multiple times.
Chamelia722
Posts: 2
Joined: Mon Dec 13, 2021 5:01 pm

Re: Multiple resize (or other actions) per input

Post by Chamelia722 »

Thank you for your kind replay @cday !

Indeed using a shell script (or anything of the same kind) would still require to open the big file multiple times.

For now, the best trick I could think of was to cascade generations, i.e. I generate each thumbnail using the one with the size just above (e.g. my source file is 12Mpx, I load it to generate the 1024px wide thumbnail, then I load the 1024px thumbnail to generate the 512px thumbnail, then I load the 512px thumbnail to generate the 256px thumbnail, and so on)

It might (or might not) introduce a slight quality degradation but I don't mind, and it went from 1.9 seconds down to only .6 seconds
cday
XnThusiast
Posts: 3258
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Multiple resize (or other actions) per input

Post by cday »

Chamelia722 wrote: Mon Dec 13, 2021 6:50 pm Indeed using a shell script (or anything of the same kind) would still require to open the big file multiple times.

For now, the best trick I could think of was to cascade generations, i.e. I generate each thumbnail using the one with the size just above (e.g. my source file is 12Mpx, I load it to generate the 1024px wide thumbnail, then I load the 1024px thumbnail to generate the 512px thumbnail, then I load the 512px thumbnail to generate the 256px thumbnail, and so on)
Actually, depending on exactly what you need to do, in a shell script you should be able to use the output of each resize as the input for the next resize, with a resulting reduction in processing time... :D


Edit:

This post Re: Convert image files to multiple outputs is the code for a batch file to do about that, if my memory is correct, that I wrote several years ago to meet, I think, the original poster's slightly more complex need.