$fn = $action->convertExists($this->fn, $x, $y);
}
-
+
if (!$fn) {
return false;
}
function convert($toMimetype, $x= 0, $y =0, $pg=false)
{
//print_R(func_get_args());
- $pg = (int) $pg;
+ if ($toMimetype == 'image/jpg') {
+ $toMimetype = 'image/jpeg';
+ }
- if(empty($pg) || is_nan($pg * 1)){
+ $pg = (int) $pg;
+ if(empty($pg) || is_nan($pg * 1)){
$pg = false;
}
$fn = $this->fn;
}
-
+
+
if (preg_match('#^image/#', $toMimetype) && $toMimetype != 'image/gif' && ( !empty($x) || !empty($y))) {
//var_dump(array($toMimetype));
+
require_once 'File/Convert/Solution.php';
$scf = (strpos($x, 'c') !== false ? 'scaleimagec' : 'scaleimage' );
require_once 'File/Convert/Solution/'. $scf . '.php';
$scls = 'File_Convert_Solution_' . $scf;
-
$sc = new $scls($toMimetype, $toMimetype);
- $sc->debug= $this->debug;
+ $sc->debug= $this->debug;
$this->solutions[] = $sc;
$x = str_replace('c', 'x', $x);
$x = strlen($x) ? (int) $x : '';
$y = strlen($y) ? (int) $y : '';
//print_r($x); print_r(' > '); print_r($y);exit;
+
$fn = $sc->runconvert($fn, $x, $y, $pg);
-
+
}
// print_r($this->target);
$this->target = $fn;
return false;
}
if (!$this->ext) {
- return false;
+ die("missing mimetype");
+
}
$this->debug("runconvert : {$fn}, {$x}, {$y}, {$pg}");
function convert($fn,$x,$y,$pg)
{
- // print_r(array('scaleimage', func_get_args()));
- clearstatcache();
+ clearstatcache();
if (!file_exists($fn) || (empty($x) && empty($y))) {
+
return false;
}
$ext = $this->ext;
$this->debug("COVERT: FE:" . (file_exists($target) ? 1: 0) );
$this->debug("COVERT: FS:" . (file_exists($target) ? (filemtime($target) . '>' . filemtime($fn)) : 'n/a'));
-
+
if ($this->debug < 2 && file_exists($target) && filesize($target) && filemtime($target) > filemtime($fn)) {
$this->debug("SCALEIMAGE - image exists $target");
return $target;
//echo "GOT TARGET" . $target;
list($width, $height) = @getimagesize($fn);
-
+
$extent = '';
switch (true) { // what about fit/pad etc...
$extent ="-extent '{$x}x{$y}>' -gravity center -background white {$define}";
break;
}
+
require_once 'System.php';
$CONVERT = System::which("convert");
- //var_dump($CONVERT);
- if ($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?
$cmd = "{$CONVERT} " . $strip . " -colorspace sRGB -interlace none -density 800 -quality 90 ".
(strlen($scale) ? " {$resize_method} '{$scale}' " : '' ).
$extent . " '{$fn}' '{$targetName}'";
- //var_dump($cmd);exit;
- $cmdres = $this->exec($cmd);
+ $cmdres = $this->exec($cmd);
$this->exec($cmd);
array( 'video/vnd.mpegurl', array('m4u')),
array( 'video/x-flv', array('flv')),
array( 'video/ogg', array('ogv')),
+
+
+
),
function toExt($mtype)
{
$mtype = strtolower($mtype);
+ switch($mtype) {
+ case 'image/jpg':
+ $mtype = 'image/jpeg';
+ break;
+ // any others.?
+ }
+
$mtl = $GLOBALS['File_MimeType'];
+
foreach($mtl as $mtd) {
if ($mtd[0] == $mtype) {
return $mtd[1][0];