Skip to content

Commit

Permalink
Merge pull request #15 from jdiderik/patch-1
Browse files Browse the repository at this point in the history
Update to preserve transparancy in PNGs
  • Loading branch information
apeisa committed Feb 19, 2014
2 parents 9e1a36e + c78d003 commit 563537e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ProcessCropImage/ProcessCropImage.module
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ FORM;
if($crop['w']>0 && $crop['h']>0) {
$img_r = imagecreatefromstring(file_get_contents($targetPath));
$dst_r = imagecreatetruecolor($crop['w'], $crop['h']);
imagealphablending($dst_r, false);

imagecopy($dst_r, $img_r, 0, 0, $crop['x1'], $crop['y1'], $crop['w'], $crop['h']);
// we write to file
switch($extension) {
Expand All @@ -287,6 +289,7 @@ FORM;
case 'png':
// convert 1-100 (worst-best) scale to 0-9 (best-worst) scale for PNG
$quality = round(abs(($jpeg_quality - 100) / 11.111111));
imagesavealpha($dst_r, true);
imagepng($dst_r,$targetPath,$quality);
break;
case 'jpeg':
Expand Down

0 comments on commit 563537e

Please sign in to comment.