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, xnview

Post Reply
cday
XnThusiast
Posts: 2212
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 » Wed Jul 24, 2019 5:21 pm

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: 2212
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 » Fri Jul 26, 2019 2:05 pm

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: 32005
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

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

Post by xnview » Tue Sep 03, 2019 3:51 pm

will be added in next version
Pierre.

cday
XnThusiast
Posts: 2212
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 » Wed Sep 04, 2019 11:44 am

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: 2212
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 » 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].

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

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

Post by xnview » Thu Sep 05, 2019 5:20 am

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.

Post Reply