BAT files: missing parametres ?

XnConvert Multi Platform - Windows, MacOSX, Linux

Moderators: helmut, XnTriq, xnview

Post Reply
payaxnv
Posts: 23
Joined: Sat Jan 10, 2009 2:40 pm

BAT files: missing parametres ?

Post by payaxnv »

Hello;
i have a little script doing well within xnconvert
1:Niveaux, avec Luminosité: 0...210 & sortie 0...255
2:Redimensionner: coté le plus court = 1400
works well in the prog itself :P
in .xbs we get all the parameterss:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?><XnView_script version="1.0" name="nc21_levels210_1400">
    <Levels in_low="0,0,0,0," in_high="210,255,255,255," out_low="0,0,0,0," out_high="255,255,255,255," gamma="1,1,1,1," mode="0"/>
    <Resize mode="2" width="1400" height="0" unit="0" ratio="true" orientation="false" enlarge="0" resample="7" gamma_correct="false"/>
    <Output folder="" filename="nb_{Filename}" case="0" startIndex="1" format="JPEG">
        <Options overwrite="1" orgDate="false" keepMeta="false" keepICC="false" keepFolder="false" keepParentFolder="false" keepExtension="true" delOrg="false" multipage="false" allPages="false" openExplorer="false" openBrowser="false" clearItems="false"/>
        <JPEG quality="90" progressive="false" optimizeHuffman="true" rebuildThumb="true" orgQuality="false" DCTMethod="0" subSampling="0" smoothFactor="0"/>
    </Output>
</XnView_script>
But when exporting (.bat), levels adjust disapers :(

Code: Select all

nconvert  -ratio -rtype lanczos -resize shortest 1400  -out jpeg -q 90 -opthuff 
Bug or Normal ?

PS In nconvert help:

Code: Select all

-levels b w       : Levels
rather short :mrgreen:
payaxnv
Posts: 23
Joined: Sat Jan 10, 2009 2:40 pm

Re: BAT files: missing parametres ?

Post by payaxnv »

auto answer :P
i had an old help text for nconvert (on the forum).
the new one shows:

Code: Select all

          -levels b w       : Levels
          -levels2 in_low in_high gamma out_low out_high : Levels
          
This is the params in the XBS file:

Code: Select all

<Levels in_low="0,0,0,0," in_high="210,255,255,255," out_low="0,0,0,0," out_high="255,255,255,255," gamma="1,1,1,1," mode="0"/>
so i believe syntax coild be like:

Code: Select all

 -levels2 "0,0,0,0," "210,255,255,255," "1,1,1,1," "0,0,0,0," "255,255,255,255,"
is that right ?
User avatar
xnview
Author of XnView
Posts: 46235
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: BAT files: missing parametres ?

Post by xnview »

The levels in NConvert is not the same :(

Code: Select all

-levels2 0 210 1 0 255
Pierre.
payaxnv
Posts: 23
Joined: Sat Jan 10, 2009 2:40 pm

Re: BAT files: missing parametres ?

Post by payaxnv »

Bonsoir Pierre
Encore merci pour votre programme.
Si j'ai bien compris l'export pour nconvert (pour les paramètres de niveaux) ne fonctionne pas ?

j'ai essayé de mon coté avec (morceau de BAT) en copiant les valeurs du script XBS:

Code: Select all

set in_low= "0,0,0,0,"
set in_high= "220,255,255,255,"
set gamma= "1,1,1,1,"
set out_low="0,0,0,0,"
set out_high= "255,255,255,255,"

set nc_level=-levels2 %in_low% %in_high% %gamma% %out_low% %out_high%
%nconvert_path64% %a_quiet% %nc_level% -overwrite -out bmp -dpi 72 -resize %taille_o% 0 -ratio -rtype lanczos -subsampling 2 -o img_%taille_o%_### *.*

echo creation du pdf %taille_o%
if exist *_%taille_o%_*.bmp %nconvert_path64% %a_quiet% -multi -out pdf -c 5 -q 90 -o $$_%taille_o%_ORI_RSD.pdf *_%taille_o%_*.bmp
Ce bout de script fonctionne. Avec (apparemment) une correction des niveaux comme attendu.
Peut être que c'est un hasard :shock: , nconvert n’interprète peut être que le premier élément de la chaine passée en argument ?
Alors comment fait on si on modifie plusieurs paramètres de niveaux ?

PS: vous aurez deviné
%nconvert_path64%= localisation de nconvert.exe
%a_quiet% = verbose ou pas
%taille_o% = taille de redimensionnement
& deuxième partie pour créer un pdf avec les images réajustées.
cday
XnThusiast
Posts: 4394
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: BAT files: missing parametres ?

Post by cday »

Bonsoir ou bonjour,

I hesitate to post with my limited experience using variables in CMD, but wouldn't variables for use in Pierre's example above be coded as follows:

Code: Select all

-levels2 0 210 1 0 255

Code: Select all

set in_low=0
set in_high=210
set gamma=1
set out_low=0
set out_high=255

But as a variable can contain spaces, apparemment, the following simpler code could probably also be used:

Code: Select all

set value= "0 210 1 0 255"
So:

Code: Select all

-levels2 %value%
It might be as well to take a closer look than I have at this reference, for example, though.

Although I have been using a computer since Windows 3.11, I never expected to use the command line... :wink:
User avatar
xnview
Author of XnView
Posts: 46235
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: BAT files: missing parametres ?

Post by xnview »

payaxnv wrote: Tue Oct 26, 2021 4:14 pm Si j'ai bien compris l'export pour nconvert (pour les paramètres de niveaux) ne fonctionne pas ?
Non, c'est simplement que NConvert & XnConvert n'utilisent pas les mêmes parametres pour 'levels'

Avez vous essayé avec

Code: Select all

-levels2 0 210 1 0 255
?
Pierre.
payaxnv
Posts: 23
Joined: Sat Jan 10, 2009 2:40 pm

Re: BAT files: missing parametres ?

Post by payaxnv »

@ Pierre
ca marche :)
si j'ai bien compris avec Xnconvert le script enregistre plus de données:

Code: Select all

<Levels in_low="10,0,0,0," in_high="224,255,255,255," out_low="0,0,0,0," out_high="255,255,255,255," gamma="1,1,1,1," mode="0"/>
qui sont simplifiées avec nconvert en :

Code: Select all

-levels2 10 224 1 0 255
avec un petit plus qui concerne l'ordre des paramètres :wink:
Merci encore une fois pour ce programme.
payaxnv
Posts: 23
Joined: Sat Jan 10, 2009 2:40 pm

Re: BAT files: missing parametres ?

Post by payaxnv »

@cday
hello
with:

Code: Select all

set in_low= "0,0,0,0,"
set in_high= "220,255,255,255,"
set gamma= "1,1,1,1,"
set out_low="0,0,0,0,"
set out_high= "255,255,255,255,"
set nc_level=-levels2 %in_low% %in_high% %gamma% %out_low% %out_high%
echo %nc_level%
pause
we get:

Code: Select all

-levels2  "0,0,0,0,"  "220,255,255,255,"  "1,1,1,1," "0,0,0,0,"  "255,255,255,255,"
this is quite exactely all the caracters.
concataining strings in bat includes all caracters (here the spaces between VAR)
it is the same that:

Code: Select all

-levels2  0 220 1 0 255 
So Pierre could confirm, nconvert reeds levels2 params as 5 blocks and extract first number for each one (i believe)

it s much easy to write second way (-levels2 0 220 1 0 255 ) wich is OFFICIAL way

so you can write something like

Code: Select all

set in_low= 0
set in_high= 220
set gamma= 1
set out_low= 0
set out_high= 255

%nc% -dpi 96  -levels2 %in_low% %in_high% %gamma% %out_low% %out_high% -out tiff -c 4  -o $$_%taille_o%_ORI_###.tiff *.jpg
or more compact:

Code: Select all

set in_low= 0
set in_high= 220
set gamma= 1
set out_low= 0
set out_high= 255

set nc_level=-levels2 %in_low% %in_high% %gamma% %out_low% %out_high%
%nc% -dpi 96  %nc_level% %nc_resize% -out tiff -c 4  -o $$_%taille_o%_ORI_###.tiff *.jpg
PS: TRY CLI and BAT it's magic
Post Reply