Request: Option to 'Convert only if specified file parameter condition is satisfied'

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, helmut, xnview

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

Request: Option to 'Convert only if specified file parameter condition is satisfied'

Post by cday »

There are requests from time to time to be able to convert images only if a specified file parameter condition is satisfied, for example only if 'pixel height is greater than 720px' or only if 'filesize is greater than 1000kb'.

A recent thread Pull out image height requested a way to copy a specified image file parameter to a variable, which could then be used in a script. That could have general application, but would require familiarity with a scripting language.

Another possible solution might be to add a new NConvert option to convert an image only if a specified file parameter condition is satisfied; as access to file parameters is already available, that might not be difficult to implement. :D

Initial support might be for: height | width | filesize set to | greater than | less than .

So maybe something like:

Code: Select all

-convert height_px greater_than 720 
cday
XnThusiast
Posts: 4172
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Request: Option to 'Convert only if specified file parameter condition is satisfied'

Post by cday »

If this option can be implemented the following notation, or parts of it, might possibly be clearer:

Code: Select all

-only height greater 720

Alternatively the number of arguments could be reduced by using:

Code: Select all

-only_greater height 720

I think this function could be quite useful... :D
User avatar
xnview
Author of XnView
Posts: 44761
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Request: Option to 'Convert only if specified file parameter condition is satisfied'

Post by xnview »

will be added in next version
Pierre.
cday
XnThusiast
Posts: 4172
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Request: Option to 'Convert only if specified file parameter condition is satisfied'

Post by cday »

xnview wrote: Tue Sep 03, 2019 3:51 pm will be added in next version
Thanks for including in NConvert 7.32... :D

Looks like a small typo in the help file:

Code: Select all

 -greater_than type value  : Process only if arg is less than value: Overwrite existing file
 -less_than type value     : Process only if arg is less than value
       type : height width filesize
First line less -> greater

And is 'Overwrite existing file' in the first line intended??
cday
XnThusiast
Posts: 4172
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Request: Option to 'Convert only if specified file parameter condition is satisfied'

Post by cday »

Continued...

Tested - six combinations - all work! :D

If possible, could the help file indicate that height and width are pixels [pretty obvious] and that the filesize parameter is *bytes* [less obvious but understandable].
User avatar
xnview
Author of XnView
Posts: 44761
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Request: Option to 'Convert only if specified file parameter condition is satisfied'

Post by xnview »

cday wrote: Wed Sep 04, 2019 4:37 pm Continued...

Tested - six combinations - all work! :D

If possible, could the help file indicate that height and width are pixels [pretty obvious] and that the filesize parameter is *bytes* [less obvious but understandable].
ok :)
Pierre.
greenslade_
Posts: 1
Joined: Sun May 10, 2020 9:22 pm

Re: Request: Option to 'Convert only if specified file parameter condition is satisfied'

Post by greenslade_ »

Is there a way of getting "longest" as there is in the resize function?