Version: 0.5
Type: Full Script
Category: Graphics
License: GNU General Public License
Description: Reads EPS-image information of all images in a folder.
Delivers width, height, resolution (rounded), and decides if EPS is CMYK or other color format.
This is my first version, trying to work on it in future but for me its ok right now.
If someone is able to calculate resolution more properly, hey you’re welcome.
Same for color type
<?php //*************************************************************************** // Reads folder and gets information about EPS-Images * // (c) 2003 by Florian Schaeffer, Mercoline GmbH * //*************************************************************************** // part of the code based upon script from www.phpbuilder.com * // URL: https://phpbuilder.com/snippet/browse.php?by=cat&cat=7 * // by quicknik * //*************************************************************************** // Version 0.5 * // Last update: 20.01.2003 * // Contact: [email protected] * //*************************************************************************** //*************************************************************************** // According to Adobe EPSfileSpecs * // http://partners.adobe.com/asn/developer/technotes/postscript.html * // Direct download of PDF * // http://partners.adobe.com/asn/developer/pdfs/tn/5002.EPSF_Spec.pdf * // EPS files must have parameter BoundingBox * // optionally most of them have parameter ImageData * // BoundingBox defines width and height of picture in points * // (72 points = 1 Inch) * // ImageData holds Image width and height in pixels * // If Document is CMYK there is also a parameter DocumentProcessColors * //*************************************************************************** //*************************************************************************** // for use on Windows * //*************************************************************************** $img_path = "e:erisbilderhq_diplomat"; // enter Imagepath - Windows style //*************************************************************************** // uncomment for use on unix * //*************************************************************************** // $img_path = "/path/to/images/"; // enter Imagepath - UNIX style ?> <html> <head> <title>EPSInfo</title> </head> <body> <table border="0" width="80%" cellspacing="2" cellpadding="0"> <tr bgcolor="#cccccc"> <th>Name</th><th>Width</th><th>Height</th><th>Resolution</th><th>Mode</th></tr> <?php // read EPS data of given filename function read_eps($img){ $fp=fopen ($img, "rb"); $buffer = fread($fp, 4096); // assume information is in first 4096 bytes if (!preg_match("/ImageData:[^"]*"/",$buffer ,$imgdataln)) { // if not, try first 10kbyte fclose($fp); $fp=fopen ($img, "rb"); $buffer = fread($fp, 100000); if (!preg_match("/ImageData:[^"]*"/",$buffer ,$imgdataln)) { // if still not found, try whole file fclose($fp); $fp=fopen ($img, "rb"); $buffer = fread($fp,filesize($img)); preg_match("/ImageData:[^"]*"/",$buffer ,$imgdataln); } } $imgdata=split(" ", $imgdataln[0]); // Read image width and height if (preg_match("/BoundingBox:[^"]*"/",$buffer ,$imgdataln2)) { $imgdata2=split(" ", $imgdataln2[0]); // Read Bounding data } if (preg_match("/DocumentProcessColors:[^"]*"/",$buffer ,$imgdataln3)) { $imgcolour=split(" ", $imgdataln3[0]); //Read Color format } fclose ($fp); $imgwidth=$imgdata[1]; // get image width $imgheight=$imgdata[2]; // get image height if ($imgdata2[3] > 0) { $imgres=(72/$imgdata2[3])*$imgdata[1];} // calculate image resolution in dpi if ((290 < $imgres) and ($imgres < 310)) {$imgres=300;} // make it look like 300 dpi if ($imgcolour[1]=="Cyan") { $imgcolor = "CMYK"; // make Color look like CMYK } else { $imgcolor = "no CMYK information found"; } if ($imgwidth[1]=='') { $bgcolor='#FFAAAA'; } else { $bgcolor='#AAFFAA'; } print "<tr bgcolor='$bgcolor'><td>".$img."</td>n"; // print tablerow print "<td align="right">".$imgwidth." px</td>n"; print "<td align="right">".$imgheight." px</td>n"; print "<td>".round($imgres)." dpi</td>n"; print "<td>".$imgcolor."</td>n"; } chdir($img_path); // first move to image path $fh = opendir("."); // open filehandle while (($filen = readdir($fh)) !== false) // read all files in folder { if (($filen != ".") && ($filen != "..")) { read_eps($filen); } } closedir($fh); ?> </table> </body> </html>