Reputation: 5355
I've got a PDF with multiple pages that I have used pdftk
and imagemagick
to split and convert into png's using the below script. Problem is that some of the pages of my PDF are black and white and others are colour, and this means that some of my images are saving as single channel and the rest are three channel. This is causing me issues down the line, and would be best to fix here.
Does anyone know how I can force my black and white images to have three channels, ideally using convert
?
#!/bin/bash
for i in {1..105}
do
pdftk FNAME-12A.pdf cat $i output FNAME-12A_$i.pdf
convert -density 128 FNAME-12A_$i.pdf -quality 100 -channel RGB FNAME-12A_$i.png
done
Upvotes: 4
Views: 1566
Reputation: 207475
Prefix the output filename with PNG24:
convert something ... PNG24:output.png
For the sake of completeness and future reference, you can also use the following to force PNG variants:
Upvotes: 8