cday wrote:
That [NConvert command line] seemed to work well for the letters I tested initially which were black and white scans ... but failed when I tested a colour scan: the problem seemed to be that when the image was converted to paletted colour, nominally white canvas wasn't converted to pure white even when I reduced the colour depth right down to 8 colours. It seemed to be necessary to determine the actual paletted colour in a test conversion so that that value could be set, the actual value depending on the bit depth valued entered. Even when the background colour was 255 255 255, the paletted value wasn't pure white. That problem doesn't arise with the GUI solutions you posted, I presume.
XnTriq wrote:
cday wrote:That problem doesn't arise with the GUI solutions you posted, I presume.
No difference. That's the crux of the matter: You'd need a way to tell XnView (or nConvert) to generate a
common palette for a batch of files. As a workaround, I use GIF animation software…
When a colour image is converted to paletted colour, each colour present in the source image is converted to one or other of the [reduced number] of colours in the palette according to some algorithm, which may or may not be the same algorithm used in other software applications?
Considering the case of converting scans of documents which have a nominally white background, the exact R G B values of the nominally white backgrounds might differ slightly, but one would expect them all to be mapped to the "white" colour in the platette created?
With the GUI solutions it is possible to select the "white" colour in the palette as the colour to be used for transparency, without knowing the actual R G B values of that palette colour, and all the nominally white background images should normally be successfully converted?
With NConvert [sic

] successful conversion seemed to require the actual "white" palette R G B value to be entered in the code, but that value could only be found be found by examining an image that had been [unsuccessfuly] processed... Further, the actual "white" palette colour produced by the algorithm used by NConvert seemed to vary depending on the number of colours in the palette that was created.
So that is a difference between NConvert and GUI solutions? All based on very brief tests, though, and the NConvert conversion algorithm could in principle produce different "white" palette values depending on the actual rather than nominal number of colours in the source image, although I imagine that probably isn't the case.
Regarding test files, I don't think that there was anything at all special about the small number of files I used. I had a number of letters scanned using a multifuntion device in the library, with which I have some familiarity, but wanted to use the sheet feeder and was feeling a bit lazy so I asked a member of staff to scan them in colour to JPEGs. When I checked them later, I found that they had actually been scanned to black and white (possibly because the scanner had correctly detected that there was no colour in those letters and overridden the colour setting, but I'm not sure about that).
I therefore tested those files first with good results once I got the right code; considering the discussion above, possibly the
-colors 256 setting was required to obtain success with the R G B 255 255 255 setting I entered, just luck possibly. Because I wanted to be able to add colour highlighting to some images, I then converted them to 24-bit (in any one of three possible programs, I don't recall which one) and tested those without initial success, then additionally tried using a Levels adjustment (in XnView MP) to whiten the background of an image slightly, and started monitoring the actual background R G B using the XnView Classic 'Display Colour Information' tool.
Using those files, but any other would probably do, I then traced the problem I was having to the apparent fact that the nominally "white" palette colour created by the NConvert code wasn't 255 255 255, the actual value possibly depended on the number of palette colours selected, and it seemed to be necessary to enter the exact R G B value to obtain a successful conversion to transparency.
All rather provisional and based on only a small number of tests, but once the details have been confirmed an NConvert batch file looks like a potentially useful one-step way of performing regular transparency conversions as directly as possible...