Page 1 of 1
Convert entire folder to 8-bit
Posted: 2013-08-13T13:42:25-07:00
by acoustic7
I have seen something like this question in a few other places around the site.
I need to convert a folder of pngs to 8-bit.
convert original.png -auto-level -depth 8 -define quantum:format=unsigned -type grayscale test.png
works for an individual photo,
and I tried mogrify -format png -depth 8 *.png on the directory but I don't think it worked. Both of those commands I found on other topics. Anyone have any idea how to use mogrify (i assume) to make all of these images 8-bit?
Re: Confert entire folder to 8-bit
Posted: 2013-08-13T13:57:36-07:00
by fmw42
You need the png equivalent of this -define to be able to set the output in mogrify to PNG8 (PNG24 and PNG32).
viewtopic.php?f=1&t=23875#p101575
I have suggested it already to the png developer, but have not heard back. Perhaps it will make it into the next version of IM, if he has not already done so.
In the mean time, try adding -type palette and or -colors 255 rather than grayscale in your mogrify command. That may work already. I do not think the quantumformat is something that either mogrify or PNG knows about. So it is likely useless.
Re: Confert entire folder to 8-bit
Posted: 2013-08-13T13:59:37-07:00
by glennrp
try "-colors 255" which should give you an 8-bit indexed PNG.
Re: Convert entire folder to 8-bit
Posted: 2013-08-13T14:14:00-07:00
by snibgo
acoustic7 wrote:I need to convert a folder of pngs to 8-bit.
What do you mean? 8 bits per pixel per channel, or 8 bits total per pixel?
Re: Convert entire folder to 8-bit
Posted: 2013-08-13T14:38:50-07:00
by fmw42
8-bits total (that is type palette using a color map)
if you want 8bits per channel and are using Q16 IM compile, then -depth 8 should be enough.
Re: Convert entire folder to 8-bit
Posted: 2013-08-13T15:03:06-07:00
by acoustic7
Thank you all for the responses!
I tried a sort of hybrid of the two commands before seeing these responses and it seems to have worked. For anyone curious, I did:
mogrify -format png -auto-level -depth 8 -define quantum:format=unsigned -type grayscale *.png
and as I said, it seems to have worked.
Thanks for the other suggestions though, I'm going to have to do this with some more images in the future, and chances are good that they won't work with the same command that these did, so -color255 and-type palette will probably come in handy.
thank you!!
Re: Convert entire folder to 8-bit
Posted: 2013-08-13T15:19:35-07:00
by snibgo
I had missed the fact that this is greyscale, so there is only one channel. Hence "bits per pixel" and "bits per channel per pixel" are the same.