Project

General

Profile

Bug #23348 ยป t3lib_stdGraphic-imageMagickIdentify-patch.php

Administrator Admin, 2010-08-04 12:32

 
<?php
/**
* Returns an array where [0]/[1] is w/h, [2] is extension and [3] is the filename.
* Using ImageMagick
*
* @param string The relative (to PATH_site) image filepath
* @return array
*/
function imageMagickIdentify($imagefile) {
if (!$this->NO_IMAGE_MAGICK) {
$frame = $this->noFramePrepended ? '' : '[0]';
$cmd = t3lib_div::imageMagickCommand('identify', $this->wrapFileName($imagefile) . $frame);
$returnVal = array();
exec($cmd, $returnVal);
$splitstring = $returnVal[0];
$this->IM_commands[] = Array('identify', $cmd, $returnVal[0]);
if ($splitstring) {
$splitinfo = explode(' ', $splitstring);
foreach ($splitinfo as $key => $val) {
$temp = '';
if ($val) {$temp = explode('x', $val);}
if (intval($temp[0]) && intval($temp[1])) {
$dim = $temp;
break;
}
}
if ($dim[0] && $dim[1]) {
return Array($dim[0], $dim[1], strtolower($splitinfo[1]), $imagefile);
}
}
}
}
    (1-1/1)