Page 1 of 1

Replace color not working in NConvert like in XnConvert

Posted: Wed Dec 11, 2019 10:01 am
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

Re: Replace color not working in NConvert like in XnConvert

Posted: Wed Dec 11, 2019 10:57 am
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?

Re: Replace color not working in NConvert like in XnConvert

Posted: Wed Dec 11, 2019 12:34 pm
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

Re: Replace color not working in NConvert like in XnConvert

Posted: Wed Dec 11, 2019 1:13 pm
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??

Re: Replace color not working in NConvert like in XnConvert

Posted: Wed Dec 11, 2019 1:58 pm
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

Re: Replace color not working in NConvert like in XnConvert

Posted: Tue Dec 17, 2019 10:37 am
by xnview
cday wrote: Wed Dec 11, 2019 1:13 pm @Pierre: Is a tolerance value not supported in NConvert??
i'll add it