fmw42 wrote: ↑2018-02-18T12:05:19-07:00
Please write your questions with respect to commands that you feel are not working as we discussed above.
Imagemgick will preserve bit depth if you do not add more colors than that bit depth allows and the output format supports that. We showed that the number of colors increases to 644, you get either 8-bit or 16-bit output depending upon PNG or TIFF
What intermediate file? What was the command and how did you test the intermediate file for bit-depth. Best to look at identify -verbose for that.
Which command created the 1-bit tiff and 1-bit test case?
See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at
http://www.imagemagick.org/discourse-se ... f=1&t=9620 for how to ask good questions. Try to ask a question with a command line and possible input and output or some means that we can reproduce your issue.
Again, I appreciate the help, so let me try again. Questions are in bold.
1. In the simple conversion after deskew case with the files I linked to above:
Code: Select all
convert -deskew 40% test.pgm test_deskew.png
the output png returns to the bit depth of the original pgm file (1 bit), even though png as a format can handle 8 bits.
Does that mean that if a format can handle the bit depth of the original file, it will be limited to that, even if the that means throwing away info?
That's a little different from "if you create more colors than your input bit-depth and the output format supports it, you will get a higher bit depth result with more colors", since png does support 8 bits, but in this case the output file doesn't have it.
2. You can see a similar thing in my modification of the example case you gave. In your example:
Code: Select all
convert xc: xc:black +append t.tiff
the bit depth of the output t.tiff is 16-bit Grayscale Gray, so that's not quite analogous to what I had, since we start out here with a high bit depth. So I forced the original depth to 1 to mimic the pgm I started with:
Code: Select all
convert xc: xc:black +append -depth 1 -resize 1000x100! <output>
Now, if I make the output "show:", the image has lots of grays in it. Same thing if I make the output a jpg. If I instead make the output "info:" or "-write mpr:output" or a png or tiff file, the result is 1-bit sRGB in the case of "info:" or the png/tiff output image is black and white (1 bit). If I write the mpr:output to a png or tiff file, I get the same results as just writing the file directly.
Why does "show:" preserve the increased depth? jpg has to be 8-bit, so that's why that file retains the depth does. Same with show:? I'd have thought not.
Also why does a simple info: say "1-bit sRGB", but -verbose output of the same shows a histogram with lots of grays and a depth of "1/16-bit"?
3. In the case of the output png and tiff, the commands are
Code: Select all
convert xc: xc:black +append -depth 1 -resize 1000x100! output.png
convert xc: xc:black +append -depth 1 -resize 1000x100! output.tiff
Why do the output files have different patterns of black and white? Specifically, the tiff has more black (50% threshold, it looks like), while png has less (75% threshold?).
So, overall, here's my current understanding of the process:
1. Start with a 1-bit image.
2. Process it in some way and thereby increase the bit depth. (Above, I used deskew, you used a resize, and I also tested with blur.)
3. Output the result to a format that can support 1-bit depth, and the extra depth goes away. These include png and tiff (and info:?). These formats do not all reduce the depth in the same way, so that, for example, the resultant png looks different from the resultant tiff.
4. Output it to a format that can't support 1-bit depth, and you get higher depth, as in jpg (and show:?).