Please replace everything from
case "gd2" :
to
break;
with
case "gd2" :
if (!function_exists('imagecreatefromjpeg')) {
return array('error' => 'PHP running on your server does not support the GD image library, check with your webhost if ImageMagick is installed', 'halt_upload' => 1);
}
if (!function_exists('imagecreatetruecolor')) {
return array('error' => 'PHP running on your server does not support GD version 2.x, please switch to GD version 1.x on the admin page', 'halt_upload' => 1);
}
if ($imginfo[2] == GIS_GIF && $CONFIG['GIF_support'] == 1)
$src_img = imagecreatefromgif($src_file);
elseif ($imginfo[2] == GIS_JPG)
$src_img = imagecreatefromjpeg($src_file);
elseif ($imginfo[2] == GIS_PNG)
$src_img = imagecreatefrompng($src_file);
else {
include_once('classPhpPsdReader.php');
$src_img = imagecreatefrompsd($src_file);
}
if (!$src_img) {
$ERROR = $lang_errors['invalid_image'];
//return false;
return array('error' => $ERROR);
}
if ($imginfo[2] == GIS_GIF) {
$dst_img = imagecreate($destWidth, $destHeight);
} else {
$dst_img = imagecreatetruecolor($destWidth, $destHeight);
if ($imginfo[2] == GIS_PNG) {
imagealphablending($dst_img, false);
}
}
imagecopyresampled($dst_img, $src_img, 0, 0, $xOffset, $yOffset, (int)$destWidth, (int)$destHeight, $srcWidth, $srcHeight);
touch($dest_file);
$fh=fopen($dest_file,'w');
fclose($fh);
//sharpen the thumb
if ($sharpen==1 && $CONFIG['enable_unsharp']==1) {
UnsharpMask($dst_img, $CONFIG['unsharp_amount'], $CONFIG['unsharp_radius'], $CONFIG['unsharp_threshold']);
}
if ($media_type != "false") {
//if a manual thumb gets generated we watermark the thumb with the media type
//we now need to get the absolute path to the thumb watermark files
$path_parts = pathinfo($CONFIG['watermark_file']);
$CONFIG['watermark_file'] = $path_parts["dirname"]."/wm_".$media_type.".png";
}
$path_parts = pathinfo($dest_file);
if (strpos($path_parts['filename'], $CONFIG['normal_pfx']) === 0) {
$watermark_file = 'images/watermark_normal.png';
} else {
$watermark_file = $CONFIG['watermark_file'];
}
if ($watermark == "true" || $media_type != "false") {
//shrink watermark on intermediate images -> If I had known that this is that �%&# with the transparency preserve... grrr
$wm_normal = (int)$CONFIG['reduce_watermark'];
if ($wm_normal > $destWidth ) {
$wm_resize = $destWidth / $wm_normal;
//load the original, huge sized logo (the one we want to size down)
$temp_logoImage = ImageCreateFromPNG($watermark_file);
//get it's size
$temp_logoW = ImageSX($temp_logoImage);
$temp_logoH = ImageSY($temp_logoImage);
//calculate new size
$logoW = (int)($temp_logoW * $wm_resize);
$logoH = (int)($temp_logoH * $wm_resize);
//we create a new, resized logo
$logoImage = imagecreatetruecolor($logoW, $logoH);
//just to be sure that transparency gets preserved
imagealphablending($logoImage, FALSE);
imagealphablending($temp_logoImage, TRUE);
//now copy and resize the big one into the temp resized img
imagecopyresampled($logoImage, $temp_logoImage, 0, 0, 0, 0, (int)$logoW, (int)$logoH, $temp_logoW, $temp_logoH);
//we do not need the temp (huge) watermark anymore
imagedestroy($temp_logoImage);
} else { // shrink not enabled or no intermediate...
$logoImage = ImageCreateFromPNG($watermark_file);
$logoW = ImageSX($logoImage);
$logoH = ImageSY($logoImage);
}
//where is the watermark displayed...
$pos = $CONFIG['where_put_watermark'];
if ($pos == "northwest") {
$src_x = 5;
$src_y = 5;
} else if ($pos == "northeast") {
$src_x = $destWidth - ($logoW + 5);
$src_y = 5;
} else if ($pos == "southwest") {
$src_x = 5;
$src_y = $destHeight - ($logoH + 5);
} else if ($pos == "southeast") {
$src_x = $destWidth - ($logoW + 5);
$src_y = $destHeight - ($logoH + 5);
} else if ($pos == "center") {
$src_x = ($destWidth/2) - ($logoW/2);
$src_y = ($destHeight/2) - ($logoH/2);
}
imagealphablending($dst_img, TRUE);
imagecolortransparent($logoImage, imagecolorat($logoImage, $CONFIG['watermark_transparency_featherx'], $CONFIG['watermark_transparency_feathery']));
ImageCopy($dst_img,$logoImage,$src_x,$src_y,0,0,$logoW,$logoH);
}
if ($imginfo[2] == GIS_PNG) {
imagesavealpha($dst_img, true);
imagepng($dst_img, $dest_file, round((100 - $CONFIG['jpeg_qual']) / 10));
} else {
imagejpeg($dst_img, $dest_file, $CONFIG['jpeg_qual']);
}
imagedestroy($src_img);
imagedestroy($dst_img);
break;