function convertExists($toMimetype, $x= 0, $y =0)
{
+ $fn = $this->fn;
if ($toMimetype != $this->mimetype) {
$action = $this->getConvMethods($this->mimetype, $toMimetype);
return false;
}
$fn = $action->convertExists($this->fn, $x, $y);
- } else {
- $fn = $this->fn;
}
+
if (!$fn) {
return false;
}
+
if (!preg_match('#^image/#', $toMimetype) || ( empty($x) && empty($y))) {
return $fn;
}
+
//echo "testing scale image";
require_once 'File/Convert/Solution.php';
$sc = new File_Convert_Solution('scaleImage', $toMimetype, $toMimetype);
if(empty($pg) || is_nan($pg * 1)){
$pg = false;
}
-
+ $fn = $this->fn;
//echo '<PRE>'; print_r(array('convert', func_get_args()));
if (
$toMimetype != $this->mimetype ||
// let's assume that conversions can handle scaling??
- } else {
- $fn = $this->fn;
- }
-// if(!strpos($x, 'c')){
-// print_r('inin?');
-// print_r($x);
-// print_r(' > ');
-// print_r($y);exit;
-//
-//// $size = explode('c', $x);
-// }
-// print_r(strpos($x, 'c'));
-// print_r(' > ');
-// print_r($y);exit;
-// print_r($this->fn);exit;
+ }
+
if (preg_match('#^image/#', $toMimetype) && $toMimetype != 'image/gif' && ( !empty($x) || !empty($y))) {
//var_dump(array($toMimetype));
require_once 'File/Convert/Solution.php';
}
function scaleImage($fn, $x, $y)
{
+
+
// print_r(array('scaleimage', func_get_args()));
if (empty($x) && empty($y)) {
return false;
$target = $fn . '.'.$x.'x'.$y.'.' . $ext;
- if (file_exists($target) && filesize($target) && filemtime($target) > filemtime($fn)) {
+ if (empty($this->debug) && file_exists($target) && filesize($target) && filemtime($target) > filemtime($fn)) {
return $target;
}
//var_dump($CONVERT);
if ($CONVERT) {
// note extend has to go after the resize.. so it does that first...
- // changed to using 'sample' rather than resize -- it's alot faster? - not sure about quality though?
+ // changed to using 'sample' rather than resize
+ //-- it's alot faster? - not sure about quality though?
+ //
+ $resize_method = filesize($fn) > 300000 ? '-sample' : '-scale';
+
$cmd = "{$CONVERT} " . $strip . " -colorspace sRGB -interlace none -density 800 -quality 90 ".
- " -sample '{$scale}' ". $extent . " '{$fn}' '{$targetName}'";
+ " {$resize_method} '{$scale}' ". $extent . " '{$fn}' '{$targetName}'";
- $cmdres = $this->exec($cmd);
+ $cmdres = $this->exec($cmd);
$this->exec($cmd);