NConvert useage: option -n

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

Moderators: XnTriq, helmut, xnview

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

NConvert useage: option -n

Post by cday »

Could someone please provide an explanation for the operation of the following option listed in the help file:

Code: Select all

-n start end step : Begin End Step (for image sequence)
The option dates back to the early days of NConvert, but I am unable to find any explanation of its operation, intended useage or example of its use through searching the forum or a Google search...

Our forum librarian, who has uncanny search powers :?:

Helmut who was any early NConvert user :?:
User avatar
oops66
XnThusiast
Posts: 2005
Joined: Tue Jul 17, 2007 1:17 am
Location: France

Re: NConvert useage: option -n

Post by oops66 »

Hello ... A sample with option -n is into the xnview wiki, did not help?
http://www.xnview.com/wiki/index.php/NC ... User_Guide

Code: Select all

    ou can use it with images sequences. 
For example, to convert the files file00.pic, file01.pic, ..., file10.pic and we convert to jpeg format with the name pattern res0.jpg, res1.jpg, ... type :
nconvert -out jpeg -n 1 10 1 -o res#.jpg file##.pic
[/color]
XnViewMP Linux X64 - Debian - X64
User avatar
XnTriq
Moderator & Librarian
Posts: 6387
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: NConvert useage: option -n

Post by XnTriq »

Hi cday :-)
This is what I've got (so far):
XnView Wiki ([url=http://www.xnview.com/wiki/index.php/NConvert_User_Guide]NConvert User Guide[/url]) wrote:You can use it with images sequences.
For example, to convert the files file00.pic, file01.pic, ..., file10.pic and we convert to jpeg format with the name pattern res0.jpg, res1.jpg, ... type :

Code: Select all

nconvert -out jpeg -n 1 10 1 -o res#.jpg file##.pic
SS64 (Windows CMD » [url=http://www.ss64.com/nt/for.html]FOR - Looping commands[/url]) wrote:syntax-FOR-List of numbers
FOR /L %%parameter IN (start,step,end) DO command
<edit> Chapeau, Monsieur oops66 ! </edit>
cday
XnThusiast
Posts: 4186
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: NConvert useage: option -n

Post by cday »

oops66 wrote:Hello ... A sample with option -n is into the xnview wiki, did not help?

http://www.xnview.com/wiki/index.php/NC ... User_Guide

Code: Select all

You can use [NConvert] with images sequences.
 
For example, to convert the files file00.pic, file01.pic, ..., file10.pic and ... to jpeg format with the name pattern res0.jpg, res1.jpg, ... type :

nconvert -out jpeg -n 1 10 1 -o res#.jpg file##.pic
[/color]
[Code edited to increase clarity.]

Thank you, that didn't show up in my searches, and the Wiki's are not a resource I normally think to turn to as they are often very limited or out of date.

That confirms the use of -n but I think I might have to do some tests to fully understand it...
cday
XnThusiast
Posts: 4186
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: NConvert useage: option -n

Post by cday »

And thanks also to XnTriq whose usual wealth of links will hopefully provide some further insight... :D
User avatar
XnTriq
Moderator & Librarian
Posts: 6387
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: NConvert useage: option -n

Post by XnTriq »

cday wrote:Thank you, that didn't show up in my searches, and the Wiki's are not a resource I normally think to turn to as they are often very limited or out of date.
As it turns out, this info was transferred from Usage.txt to the Wiki.
nconvert command line option Japanese translation wrote:You read the file with a serial number. Option is to condition such as "-n 1 15", "- n [start number] [end number]" Please enter in the format.
User avatar
oops66
XnThusiast
Posts: 2005
Joined: Tue Jul 17, 2007 1:17 am
Location: France

Re: NConvert useage: option -n

Post by oops66 »

cday wrote:...Thank you, that didn't show up in my searches, and the Wiki's are not a resource I normally think to turn to as they are often very limited or out of date.
That confirms the use of -n but I think I might have to do some tests to fully understand it...
Hello Cday & Xntriq, you're welcome ... yes some others tests are needed too.
XnViewMP Linux X64 - Debian - X64
cday
XnThusiast
Posts: 4186
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: NConvert useage: option -n

Post by cday »

Code: Select all

-n start end step : Begin End Step (for image sequence)
http://www.xnview.com/wiki/index.php/NC ... User_Guide[/url]

You can use [NConvert] with images sequences.

For example, to convert the files file00.pic, file01.pic, ..., file10.pic and ... to jpeg format with the name pattern res0.jpg, res1.jpg, ... type :

nconvert -out jpeg -n 1 10 1 -o res#.jpg file##.pic
I've been doing some [limited] tests and -n only seems to work correctly for step=1, depending on what behaviour is expected.

With 20 input files numbered test-01 to test-19 and step=2 only alternate input files are converted:

Code: Select all

nconvert -out png -n 1 20 2 -o Output-##.png test-##.png
Image_1.png
With end=40 again only alternate input files are converted, with an error message:

Code: Select all

nconvert -out png -n 1 40 2 -o Output-##.png test-##.png
Image_2.png
Am I missing something?

Edit

It looks as though step refers to the *input* file numbers, so there is no way to increment *output* file names other than by 1?

Wouldn't the expected behaviour be for all the input files to be processed, with the step applied to the output names?

That isn't really clear in the help file, if it is the case...
You do not have the required permissions to view the files attached to this post.
cday
XnThusiast
Posts: 4186
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: NConvert useage: option -n

Post by cday »

Please see the edit added at the end of the previous post!
User avatar
oops66
XnThusiast
Posts: 2005
Joined: Tue Jul 17, 2007 1:17 am
Location: France

Re: NConvert useage: option -n

Post by oops66 »

cday wrote:Please see the edit added at the end of the previous post!
... FYI, same issue uneder Linux version NCONVERT v6.17

Code: Select all

nconvert -out png -n 1 20 2 -o Output-##.png test-##.png

** NCONVERT v6.17 (c) 1991-2011 Pierre-E Gougelet (Sep 17 2012/10:50:01) **
        Version for Linux x86 (X11)  (All rights reserved)
** This is a freeware software (for non commercial use)

Conversion of test-01.png into Output-01.png OK
Conversion of test-03.png into Output-03.png OK
Conversion of test-05.png into Output-05.png OK
Conversion of test-07.png into Output-07.png OK
Conversion of test-09.png into Output-09.png OK
Conversion of test-11.png into Output-11.png OK
Conversion of test-13.png into Output-13.png OK
Conversion of test-15.png into Output-15.png OK
Conversion of test-17.png into Output-17.png OK
Conversion of test-19.png into Output-19.png OK
$ 
nconvert -out png -n 1 40 2 -o Output-##.png test-##.png
Conversion of test-01.png into Output-01.png OK
Conversion of test-03.png into Output-03.png OK
Conversion of test-05.png into Output-05.png OK
Conversion of test-07.png into Output-07.png OK
Conversion of test-09.png into Output-09.png OK
Conversion of test-11.png into Output-11.png OK
Conversion of test-13.png into Output-13.png OK
Conversion of test-15.png into Output-15.png OK
Conversion of test-17.png into Output-17.png OK
Conversion of test-19.png into Output-19.png OK
Conversion of test-21.png into Output-21.png OK
Conversion of test-23.png into Output-23.png OK
Conversion of test-25.png into Output-25.png OK
  Error: Can't open file (test-27.png)
  Error: Can't open file (test-29.png)
  Error: Can't open file (test-31.png)
  Error: Can't open file (test-33.png)
  Error: Can't open file (test-35.png)
  Error: Can't open file (test-37.png)
  Error: Can't open file (test-39.png)
XnViewMP Linux X64 - Debian - X64
User avatar
xnview
Author of XnView
Posts: 44922
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: NConvert useage: option -n

Post by xnview »

-n replace ## by the range/step specified, in your test it works for step 2
Pierre.
cday
XnThusiast
Posts: 4186
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: NConvert useage: option -n

Post by cday »

xnview wrote:-n replace ## by the range/step specified, in your test it works for step 2
Thanks, could you please post an edited version of my command line?
User avatar
oops66
XnThusiast
Posts: 2005
Joined: Tue Jul 17, 2007 1:17 am
Location: France

Re: NConvert useage: option -n

Post by oops66 »

cday wrote:
xnview wrote:-n replace ## by the range/step specified, in your test it works for step 2
Thanks, could you please post an edited version of my command line?
... I think Pierre's saying than the errors are normal, because -n replace ## (but only/mostly for the inputs files) ;-)
XnViewMP Linux X64 - Debian - X64
cday
XnThusiast
Posts: 4186
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: NConvert useage: option -n

Post by cday »

oops66 wrote:I think Pierre's saying than the errors are normal, because -n replace ## (but only/mostly for the inputs files) ;-)
Well, O.K., but ## appears in two places in the command line...

But perhaps this shines at least a little light on a seemingly little known and probably rarely used NConvert option... :?:
User avatar
oops66
XnThusiast
Posts: 2005
Joined: Tue Jul 17, 2007 1:17 am
Location: France

Re: NConvert useage: option -n

Post by oops66 »

cday wrote:... But perhaps this shines at least a little light on an seemingly little known and probably rarely used NConvert option... :?:
... Right, this -n option is not well explained into the help (nconvert -help), and the wiki example is not the good one too.
XnViewMP Linux X64 - Debian - X64