EPSInfo
Name Width Height Resolution Mode
// 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 "".$img." \n"; // print tablerow
print "".$imgwidth." px \n";
print "".$imgheight." px \n";
print "".round($imgres)." dpi \n";
print "".$imgcolor." \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);
?>