diff --git a/config/images.php b/config/images.php index af0696cd..e1056343 100644 --- a/config/images.php +++ b/config/images.php @@ -34,22 +34,8 @@ if($_POST['action']=="addimage") { if($_FILES['image']['error']==UPLOAD_ERR_OK) { //make sure its a JPEG $imagesize=getimagesize($_FILES['image']['tmp_name']); - if($imagesize[2]==1 || $imagesize[2]==2 || $imagesize[2]==3) // GIF or JPG or PNG - { - - /* Here's how to do it with GD, if GD didn't absolutely suck at - * resizing an image (thought I'd try it again, Mar30, 2010, still sucks). - $image_data = file_get_contents($_FILES['image']['tmp_name']); - $image = imagecreatefromstring($image_data); - - $w = imagesx($image); - $h = imagesy($image); - - $ratio = $h / $w; - $image100 = imagecreate(100, $ratio * 100); - imagecopyresampled($image100, $image, 0, 0, 0, 0, 100, $ratio * 100, $w, $h); - imagejpeg($image100, "../data/logo-100.jpg");*/ - + // GIF or JPG or PNG + if($imagesize[2]==1 || $imagesize[2]==2 || $imagesize[2]==3) { echo notice(i18n("Creating sized logo files:
 logo-100.gif
 logo-200.gif
 logo-500.gif
 logo.gif")); //Make the gif's @@ -76,16 +62,40 @@ if($_POST['action']=="addimage") { echo error(i18n("Error creating PNG Image files. Make sure 'convert' binary is in your path, and that 'system' function can be used")); echo notice(i18n("Creating sized logo files:
 logo-100.jpg
 logo-200.jpg
 logo-500.jpg
 logo.jpg")); - //make some PNG's as well - system("convert -resize 100 \"".$_FILES['image']['tmp_name']."\" ../data/logo-100.jpg"); - system("convert -resize 200 \"".$_FILES['image']['tmp_name']."\" ../data/logo-200.jpg"); - system("convert -resize 500 \"".$_FILES['image']['tmp_name']."\" ../data/logo-500.jpg"); - system("convert \"".$_FILES['image']['tmp_name']."\" ../data/logo.jpg"); + + /* + We do the JPG ones with GD, so we can force the transparency layer if its converting from + a GIF or PNG that has a transparency. + */ + $image_data = file_get_contents($_FILES['image']['tmp_name']); + $image = imagecreatefromstring($image_data); + + $w = imagesx($image); + $h = imagesy($image); + + $ratio = $h / $w; + + $sizes=array(100,200,500); + foreach($sizes AS $s) { + $image100 = imagecreate($s, round($ratio * $s)); + // imageantialias($image100,true); + imagecolorallocate($image100,255,255,255); + imagecolortransparent($image100,0); + imagecopyresized($image100, $image, 0, 0, 0, 0, $s, round($ratio * $s), $w, $h); + imagejpeg($image100, "../data/logo-$s.jpg",95); + imagedestroy($image100); + } + $imageorig=imagecreate($w,$h); + imagecolorallocate($imageorig,255,255,255); + imagecolortransparent($imageorig,0); + imagecopy($imageorig, $image, 0, 0, 0, 0,$w,$h); + imagejpeg($imageorig, "../data/logo.jpg",95); + imagedestroy($imageorig); if(file_exists("../data/logo-100.jpg") && file_exists("../data/logo-200.jpg") && file_exists("../data/logo-500.jpg") && file_exists("../data/logo.jpg")) echo happy(i18n("JPG Images successfully created")); else - echo error(i18n("Error creating JPG Image files. Make sure 'convert' binary is in your path, and that 'system' function can be used")); + echo error(i18n("Error creating JPG Image files. You need the GD library available in PHP to make the JPG files")); } else {