Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if a file contains raster or vector elements? (pdf, eps, ai)

Is there a way to check if a file has raster elements in it? I would be interested to do this for the .pdf, .eps and .ai formats.

If the file is only vector I am converting it to .svg and if it has some raster elements I have to convert it to .png file.

I am working in PHP but I can utilize any command line tools as well. For instance I am considering using Inkscape to do the actual conversion.

like image 969
Vladimir Avatar asked Nov 23 '11 13:11

Vladimir


2 Answers

You could run this command on pdf files and check if anything raster exists on the file:

  grep -c -i "/image" thisfile.pdf
like image 143
Yeak Avatar answered Oct 01 '22 01:10

Yeak


You could convert the image to EPS format, and search if "/ImageType" exists. The "/ImageType" means the following object is a raster image. If it doesn't exist in the whole EPS file, this EPS is a vector file.

like image 42
SuperBerry Avatar answered Oct 01 '22 01:10

SuperBerry