I was using this command - magick identify *.tif > report.csv. Just to identify all the files and images. It is working. The test file I was using was the problem.
Do you know of any way to identify gray scale and color images in a PDF?
Counting Color and Grey Scale in a directory?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Counting Color and Grey Scale in a directory?
IM can read PDF images, via Ghostscript. So you could just use *.pdf in your command.
If you want to extract raster images from PDF files, use pdfimages.
If you want to extract raster images from PDF files, use pdfimages.
snibgo's IM pages: im.snibgo.com
Re: Counting Color and Grey Scale in a directory?
Just simple as previous.
Code: Select all
for i in *.pdf;do pdfimages -list "$i"|grep gray ;done|wc -l
for i in *.pdf;do pdfimages -list "$i"|grep rgb ;done|wc -l
Re: Counting Color and Grey Scale in a directory?
Ok, I installed Ghostscript and ran the magick identify *.pdf > report.txt. This is what the results look like.
1046.pdf[0] PDF 605x791 605x791+0+0 16-bit sRGB 13438B 0.016u 0:00.018
1046.pdf[1] PDF 605x791 605x791+0+0 16-bit sRGB 33097B 0.016u 0:00.017
1046.pdf[2] PDF 616x780 616x780+0+0 16-bit sRGB 785431B 0.016u 0:00.017
How do I determine if any of them are grey scale or color? I see RGB in them but I know there isn't color in it.
1046.pdf[0] PDF 605x791 605x791+0+0 16-bit sRGB 13438B 0.016u 0:00.018
1046.pdf[1] PDF 605x791 605x791+0+0 16-bit sRGB 33097B 0.016u 0:00.017
1046.pdf[2] PDF 616x780 616x780+0+0 16-bit sRGB 785431B 0.016u 0:00.017
How do I determine if any of them are grey scale or color? I see RGB in them but I know there isn't color in it.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Counting Color and Grey Scale in a directory?
The mere act of rasterizing a PDF doesn't calculate whether each page has any colour. You could:
This finds the maximum chroma of each page. When this is zero, the page is monochrome.
Code: Select all
magick in.pdf -colorspace HCL -format %[fx:maxima.g]\n info:
snibgo's IM pages: im.snibgo.com