Order of parameters execution in the script

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

Moderators: XnTriq, helmut, xnview

Post Reply
Maxime000
Posts: 11
Joined: Thu Dec 04, 2008 8:33 am

Order of parameters execution in the script

Post by Maxime000 »

Hello,
I have a problem with resizing images containing a transparency (alpha chanel).
What I am using in my conversion script is

Code: Select all

-autocrop 5 255 255 255 
(to get an autocrop on the whithish background of the images)
and then resizing the image.
If the image has a transparent background, the autocrop will not crop anything (because the transparent color doesn't match the white color). Therefore I need to remove the transparency with

Code: Select all

-merge_alpha
This is where I have a problem : the autocroping is done before the alpha is removed. The image it produces is still not autocropped. Is there a way to make first the

Code: Select all

-merge_alpha
THEN , once the image is flattened, the

Code: Select all

-autocrop
in that order?
User avatar
xnview
Author of XnView
Posts: 43326
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Order of parameters execution in the script

Post by xnview »

With

Code: Select all

-merge_alpha -autocrop 5 255 255 255 
??
Pierre.
Maxime000
Posts: 11
Joined: Thu Dec 04, 2008 8:33 am

Re: Order of parameters execution in the script

Post by Maxime000 »

Code: Select all

-autocrop 5 255 255 255 
this is for detecting all the pixels arround the image that have the values between 250 250 250 and 255 255 255 (pure white). The autocrop will discard these pixels and try to remove them.

My complete batch is quite long with many more parameters. Maybe you'll understand better what i'm trying to do :

Here is the main part :

Code: Select all

"C:\Program Files\XnView\nconvert.exe"  -o "%% larger.bmp" -npcd 2 -size 256x256+0 -merge_alpha -ctype grey -corder inter -out bmp -autocrop 5 255 255 255 -ratio -rflag decr -rtype lanczos -resize 200 200  %1
After that I'm calling an other batch to finish the job, but it's an other story :wink:
Last edited by Maxime000 on Thu Dec 04, 2008 4:10 pm, edited 4 times in total.
Maxime000
Posts: 11
Joined: Thu Dec 04, 2008 8:33 am

Re: Order of parameters execution in the script

Post by Maxime000 »

An example of the problem :
this is the original image with a transparent area arround the central part
Image

this is what I want to obtain : the transparent part cropped and then the central part resized
Image

and this is what I get
Image
What the script does is
1- trying to crop the image,
2- cropping nothing since the transparent color is not matching the "255 255 255",
3- then transforming the transparent color in white with the "merge_alpha" command.
What I'd like to have :
1- first the "merge_alpha" command
2- then cropping the resulting image
User avatar
xnview
Author of XnView
Posts: 43326
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Order of parameters execution in the script

Post by xnview »

ok, there is a problem. Merge_alpha is always before save
Pierre.
Maxime000
Posts: 11
Joined: Thu Dec 04, 2008 8:33 am

Re: Order of parameters execution in the script

Post by Maxime000 »

Thanks for the answer.
I guess I'll have to make a first batch file that would do the alpha merging and call for a second batch for the cropping.

In the future, do you think nconvert could parse the commands in the order they are written ?
Post Reply