Replace color not working in NConvert like in XnConvert

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

Moderators: XnTriq, helmut, xnview

Post Reply
Lars
Posts: 3
Joined: Wed Dec 11, 2019 9:55 am

Replace color not working in NConvert like in XnConvert

Post by Lars »

Hi

I'm trying to do a replace color in the command line, but i can't set the Tolerance value in command line but i can do it in XnConvert.

Can somebody help with this issue?

I'm trying to do this:

Code: Select all

nconvert -multi -replace 0 0 255 255 255 255 -binary nodither -c TIFF:4 -out tiff  test.tif
but ican't figure out how to set the tolerance for the replace color
cday
XnThusiast
Posts: 3973
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Replace color not working in NConvert like in XnConvert

Post by cday »

Lars wrote: Wed Dec 11, 2019 10:01 am i''m trying to do a replace color in the command line, but I can't set the Tolerance value in command line but i can do it in XnConvert.

I'm trying to do this:

Code: Select all

nconvert -multi -replace 0 0 255 255 255 255 -binary nodither -c TIFF:4 -out tiff  test.tif
but ican't figure out how to set the tolerance for the replace color

Have you tried using the 'Export for NConvert' option on the Actions tab to see the code exported?

Note that currently only code for the selected actions is output, to which it is necessary to add the required input and output terms, and that some actions supported in XnConvert may not be supported in NConvert yet.

Regarding your code above, I see some likely errors although I am not familiar with some of the options used: does your code run to produce an output?
Lars
Posts: 3
Joined: Wed Dec 11, 2019 9:55 am

Re: Replace color not working in NConvert like in XnConvert

Post by Lars »

Yes i have used export for NConvert but it does not include the setting for Tolerance.
Yes i do get an output and it looks ok, besides that i need to remove background colors of some words, like the color blue.
The reason is that i want to convert the image to black/white and when the background color of a word is blue, it just makes a black box over the word
cday
XnThusiast
Posts: 3973
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Replace color not working in NConvert like in XnConvert

Post by cday »

Lars wrote: Wed Dec 11, 2019 12:34 pm Yes i have used export for NConvert but it does not include the setting for Tolerance.
It looks as if 'tolerance' is not supported in NConvert which would rather limit its use?

A possible theoretical workaround, if the range of blue values is small, might be to use multiple code lines with different blue values, in a batch file...

Or maybe there is some other workaround, maybe convert to index colours first, for example, I think that might work?

Yes i do get an output and it looks ok, besides that i need to remove background colors of some words, like the color blue.
The reason is that i want to convert the image to black/white and when the background color of a word is blue, it just makes a black box over the word
I noted in your code that you used -multi which is used to create a multi-page TIFF or PDF, but you don't include a -xall which is required to extract the pages of a multi-page file before conversion. Also the -c TIFF:4 term is not correct syntax, I believe.

@Pierre: Is a tolerance value not supported in NConvert??
Lars
Posts: 3
Joined: Wed Dec 11, 2019 9:55 am

Re: Replace color not working in NConvert like in XnConvert

Post by Lars »

-xall doesn't seem to be necessary to convert all the pages but yes the -c TIFF:4 was wrong it should be -c 4

nconvert -multi -replace 0 0 255 255 255 255 -binary nodither -c 4 -out tiff test.tif
User avatar
xnview
Author of XnView
Posts: 43327
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Replace color not working in NConvert like in XnConvert

Post by xnview »

cday wrote: Wed Dec 11, 2019 1:13 pm @Pierre: Is a tolerance value not supported in NConvert??
i'll add it
Pierre.
Post Reply