Skip to content

Commit dc83862

Browse files
committed
Added support for imagemagick and the jpg_quality setting
Ignore-this: 4288b6329527a4069e0fd485e3cdbfdf darcs-hash:20090608200830-7ad00-2fdc8009e320eeef2ee3194591bde7774d8d394f.gz
1 parent 1613315 commit dc83862

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

tiles.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@
4545

4646
// (re)generate
4747
if( ($data['cachet'] < $data['mtime']) || ($data['cachet'] < $data['selft']) ){
48-
tile_gd($data);
48+
if($conf['im_convert']){
49+
tile_im($data);
50+
}else{
51+
tile_gd($data);
52+
}
4953
}
5054

5155
// send
@@ -61,6 +65,8 @@
6165

6266

6367
function tile_gd($d){
68+
global $conf;
69+
6470
$img = null;
6571
if(preg_match('/\.jpe?g$/',$d['file'])){
6672
$img = @imagecreatefromjpeg($d['file']);
@@ -77,10 +83,33 @@ function tile_gd($d){
7783
$scale = image_scale($crop,abs($d['brx'] - $d['tlx']),abs($d['bry'] - $d['tly']),$d['ts'],$d['ts']);
7884
imagedestroy($crop);
7985

80-
imagejpeg($scale,$d['cache']);
86+
imagejpeg($scale,$d['cache'],$conf['jpg_quality']);
8187
imagedestroy($scale);
88+
89+
if($conf['fperm']) chmod($d['cache'], $conf['fperm']);
8290
}
8391

92+
function tile_im($d){
93+
global $conf;
94+
95+
$cmd = $conf['im_convert'];
96+
$cmd .= ' '.escapeshellarg($d['file']);
97+
$cmd .= ' -crop '.abs($d['brx'] - $d['tlx']).'x'.abs($d['bry'] - $d['tly']).'!+'.$d['tlx'].'+'.$d['tly'];
98+
99+
$cmd .= ' -resize '.$d['ts'].'x'.$d['ts'].'!';
100+
101+
$cmd .= ' -quality '.$conf['jpg_quality'];
102+
$cmd .= ' '.escapeshellarg($d['cache']);
103+
104+
#dbg($cmd); exit;
105+
106+
@exec($cmd,$out,$retval);
107+
if ($retval == 0) return true;
108+
gfx_error('generic');
109+
}
110+
111+
112+
84113
function image_scale($image,$x,$y,$w,$h){
85114
$scale=imagecreatetruecolor($w,$h);
86115
imagecopyresampled($scale,$image,0,0,0,0,$w,$h,$x,$y);

0 commit comments

Comments
 (0)