Using different input and output directories
Moderators: XnTriq, helmut, xnview
-
- Posts: 10
- Joined: Tue Mar 02, 2021 9:30 am
Using different input and output directories
Hi, everybody
I use an online translator
Please help me write a bat file.
I have the necessary settings for nconvert:
nconvert -ratio -rtype lanczos -rflag decr -rflag orient -resize 500 500 -sharpen 50 -dpi 96 -clean 95
I need to start the bat file to convert all the files in the folder:
\\srv-10\imgkatalog\ImagePriceFull\
to the folder at:
\\srv-08\exchange\Imagsmall\
I use an online translator
Please help me write a bat file.
I have the necessary settings for nconvert:
nconvert -ratio -rtype lanczos -rflag decr -rflag orient -resize 500 500 -sharpen 50 -dpi 96 -clean 95
I need to start the bat file to convert all the files in the folder:
\\srv-10\imgkatalog\ImagePriceFull\
to the folder at:
\\srv-08\exchange\Imagsmall\
-
- XnThusiast
- Posts: 4171
- Joined: Sun Apr 29, 2012 9:45 am
- Location: Cheltenham, U.K.
Re: Using different input and output directories
Using Windows CMD?
The input files must be the last (right-most) term in the command line so, for example:
For the output term please see this thread.
The input files must be the last (right-most) term in the command line so, for example:
Code: Select all
... D:\Input\*.jpg
-
- Posts: 10
- Joined: Tue Mar 02, 2021 9:30 am
Re: Using different input and output directories
Yes, I use Windows CMD
Thanks for the link, I've seen this forum thread.
But I still can't figure out how to make a bat file
Thanks for the link, I've seen this forum thread.
But I still can't figure out how to make a bat file
-
- XnThusiast
- Posts: 4171
- Joined: Sun Apr 29, 2012 9:45 am
- Location: Cheltenham, U.K.
Re: Using different input and output directories
Simple: create a text file containing your code, then save it with a .bat extension, or do I misunderstand?
It can be useful when testing to add a 'Pause' instruction on a new line after the command line, then the CMD window remains open and it is possible to read the terminal output, although when there is an error that may not actually be very helpful .
Be careful when working and editing code, not to confuse similar files with .txt and .bat extensions.
The small utility 'Open with notepad' may be worth installing, it is then possible to open .bat files directly in Notepad, so that any corresponding .txt files can be deleted reducing the risk of possible confusion.
-
- Posts: 10
- Joined: Tue Mar 02, 2021 9:30 am
Re: Using different input and output directories
Thankscday wrote: ↑Tue Mar 02, 2021 12:53 pmSimple: create a text file containing your code, then save it with a .bat extension, or do I misunderstand?
It can be useful when testing to add a 'Pause' instruction on a new line after the command line, then the CMD window remains open and it is possible to read the terminal output, although when there is an error that may not actually be very helpful .
Be careful when working and editing code, not to confuse similar files with .txt and .bat extensions.
The small utility 'Open with notepad' may be worth installing, it is then possible to open .bat files directly in Notepad, so that any corresponding .txt files can be deleted reducing the risk of possible confusion.
I'm talking about what I need to write inside the bat file
I wrote:
Code: Select all
@chcp 1251
@for /R D:\images_input\ %%A in (*.jpg *.jpeg) do "d:\D:\NConvert\nconvert" -ratio -rtype lanczos -rflag decr -rflag orient -resize 500 500 -sharpen 50 -dpi 96 -clean 95 "%%A" D:\images_output\*.jpg
-
- XnThusiast
- Posts: 4171
- Joined: Sun Apr 29, 2012 9:45 am
- Location: Cheltenham, U.K.
Re: Using different input and output directories
The problem is possibly in the detail design (syntax) of your For loop, however to be sure it would be best to test just the basic NConvert code required to perform what you need on one directory or file, then you can be sure that any remaining problem is with the For loop. You want to be sure that the NConvert code you need runs outside the loop, do you have code that does that?
I have only quite limited experience at the command line, and find For loops difficult: usually a fair amount of 'trial and error' is necessary.
You could do an online search for 'CMD for /R loop' or something similar, and then compare examples with your code.
Here is one result from a quick search: For /R
If necessary, you could then post on one of the general programming forums, you may see some in the above search, this is one example StackOverflow.
I have only quite limited experience at the command line, and find For loops difficult: usually a fair amount of 'trial and error' is necessary.
You could do an online search for 'CMD for /R loop' or something similar, and then compare examples with your code.
Here is one result from a quick search: For /R
If necessary, you could then post on one of the general programming forums, you may see some in the above search, this is one example StackOverflow.
-
- Posts: 10
- Joined: Tue Mar 02, 2021 9:30 am
Re: Using different input and output directories
Thanks, I did a little bit of For /r work.
When I use XnConvert, the conversion result is fine with me.
Then I click on the "Export for NConvert" button.
I get the text that I paste into the bat file.
After executing the bat file, the conversion takes place, but the image is different from XnConvert
Why?
When I use XnConvert, the conversion result is fine with me.
Then I click on the "Export for NConvert" button.
I get the text that I paste into the bat file.
After executing the bat file, the conversion takes place, but the image is different from XnConvert
Why?
-
- XnThusiast
- Posts: 4171
- Joined: Sun Apr 29, 2012 9:45 am
- Location: Cheltenham, U.K.
Re: Using different input and output directories
I'm glad you have found a solution!
In what respect are the images different, the visual quality, the file size or something else?After executing the bat file, the conversion takes place, but the image is different from XnConvert
The NConvert code has no JPEG quality (-q) setting, but the default value is currently 85, I think.
If necessary, could you show your latest code and upload an example of the XnConvert and the NConvert files?
-
- Posts: 10
- Joined: Tue Mar 02, 2021 9:30 am
Re: Using different input and output directories
Hi.
I have attached four images.
Original.jpg (297kb) is the original image Resize_NConvert.jpg (409kb) - this is converted by NConvert Resize_XnConvert.jpg (15) - this is converted by XnConvert Settings_XnConvert.jpg (73kb) - XnConvert conversion settings I convert in the same folder where the image is located, replacing the original
To convert using NConvert, I used the command:
I have attached four images.
Original.jpg (297kb) is the original image Resize_NConvert.jpg (409kb) - this is converted by NConvert Resize_XnConvert.jpg (15) - this is converted by XnConvert Settings_XnConvert.jpg (73kb) - XnConvert conversion settings I convert in the same folder where the image is located, replacing the original
To convert using NConvert, I used the command:
Code: Select all
@chcp 1251
@for %%A in (D:\images_Test\*.jp*) do "D:\NConvert\nconvert" -ratio -rtype lanczos -rflag decr -rflag orient -resize 500 500 -sharpen 50 -dpi 96 -clean 95 "%%A"
You do not have the required permissions to view the files attached to this post.
-
- XnThusiast
- Posts: 4171
- Joined: Sun Apr 29, 2012 9:45 am
- Location: Cheltenham, U.K.
Re: Using different input and output directories
The main difference is that the NConvert image pixel dimensions are not as expected, 500 x 500px?
Also the JPEG quality of the XnConvert image is 70, but the quality of the NConvert image is 85, the default value, as you don't have a -q 70 term.
Are there any other relevant differences?
Also the JPEG quality of the XnConvert image is 70, but the quality of the NConvert image is 85, the default value, as you don't have a -q 70 term.
Are there any other relevant differences?
-
- Posts: 10
- Joined: Tue Mar 02, 2021 9:30 am
Re: Using different input and output directories
Yes, that's right.
The image size is not 500x500
And the weight of XnConvert is 15 kb and NConvert is 409 kb. This fact is the most significant disadvantage
I tried adding -q 70, the weight decreased to 406 kb, but it's still very much
The image size is not 500x500
And the weight of XnConvert is 15 kb and NConvert is 409 kb. This fact is the most significant disadvantage
I tried adding -q 70, the weight decreased to 406 kb, but it's still very much
-
- XnThusiast
- Posts: 4171
- Joined: Sun Apr 29, 2012 9:45 am
- Location: Cheltenham, U.K.
Re: Using different input and output directories
The immediate problem is that the NConvert pixel dimensions are not as expected, I have posted a request about that: Resize -- Fit option supported?.
3000 = 6 x 500, so 3000x3000px has 36 times as many pixels as 500x500px, so a much larger file size.
Also, a detail, the JPEG sub-sampling is 1x1,1x1,1x1 rather than 2x2,1x1,1x1, which may improve quality slightly, but may also increase the file size, or maybe only increase processing time, I'm not sure.
You could try experimenting with different settings while waiting for a possible answer from Pierre the developer on whether the 'Fit' option is currently supported in NConvert, it may possibly not be, and if so the correct code to use.
-
- Posts: 10
- Joined: Tue Mar 02, 2021 9:30 am
Re: Using different input and output directories
Oh, cday, thank you so much for your help.
We will wait for the developers ' response
We will wait for the developers ' response
-
- XnThusiast
- Posts: 4171
- Joined: Sun Apr 29, 2012 9:45 am
- Location: Cheltenham, U.K.
-
- XnThusiast
- Posts: 4171
- Joined: Sun Apr 29, 2012 9:45 am
- Location: Cheltenham, U.K.
Re: Using different input and output directories
I have done some tests and determined that the -resize option, which seemed to be the likely cause of your problem, operates correctly.
But testing using the following NConvert code used in your For loop:
...the code runs as expected producing a 500x500px image until the -clean 95 option is added, it then doesn't run.
Looking at the NConvert help file, -clean 95 is not valid code, the 95 is not a valid value.
But the JPEG 3000x3000px output you reported has not been reproduced, unexplained, so you should probably examine your code and retest.
But testing using the following NConvert code used in your For loop:
Code: Select all
NConvert_x64_7.70\nconvert -ratio -rtype lanczos -rflag decr -rflag orient -resize 500 500 -sharpen 50 -dpi 96 -clean 95 Original.jpg
...the code runs as expected producing a 500x500px image until the -clean 95 option is added, it then doesn't run.
Looking at the NConvert help file, -clean 95 is not valid code, the 95 is not a valid value.
But the JPEG 3000x3000px output you reported has not been reproduced, unexplained, so you should probably examine your code and retest.