summaryrefslogtreecommitdiff
path: root/lib/exe/fetch.php
diff options
context:
space:
mode:
authors_wienecke <s_wienecke@web.de>2007-12-21 19:14:19 +0100
committers_wienecke <s_wienecke@web.de>2007-12-21 19:14:19 +0100
commite582e8b61ef6a1fd75a8fe1d507c67da8d249d4c (patch)
tree03184e53cb84c8e23a2cf265a8492319318a7d06 /lib/exe/fetch.php
parentff8e5c090a534b4cf658804ca3fa36229f5f8876 (diff)
downloadrpg-e582e8b61ef6a1fd75a8fe1d507c67da8d249d4c.tar.gz
rpg-e582e8b61ef6a1fd75a8fe1d507c67da8d249d4c.tar.bz2
transparent_gif
darcs-hash:20071221181419-3d7ce-f05705a0357412a87e7984a041ac5812eea83048.gz
Diffstat (limited to 'lib/exe/fetch.php')
-rw-r--r--lib/exe/fetch.php22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php
index d29ed9f64..92572b6ef 100644
--- a/lib/exe/fetch.php
+++ b/lib/exe/fetch.php
@@ -324,6 +324,7 @@ function resize_imageIM($ext,$from,$from_w,$from_h,$to,$to_w,$to_h){
* resize images using PHP's libGD support
*
* @author Andreas Gohr <andi@splitbrain.org>
+ * @author Sebastian Wienecke <s_wienecke@web.de>
*/
function resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h){
global $conf;
@@ -349,7 +350,7 @@ function resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h){
}
if(!$image) return false;
- if(($conf['gdlib']>1) && function_exists("imagecreatetruecolor")){
+ if(($conf['gdlib']>1) && function_exists("imagecreatetruecolor") && $ext != 'gif'){
$newimg = @imagecreatetruecolor ($to_w, $to_h);
}
if(!$newimg) $newimg = @imagecreate($to_w, $to_h);
@@ -364,6 +365,25 @@ function resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h){
imagesavealpha($newimg,true);
}
+ //keep gif transparent color if possible
+ if($ext == 'gif' && function_exists('imagefill') && function_exists('imagecolorallocate')) {
+ if(function_exists('imagecolorsforindex') && function_exists('imagecolortransparent')) {
+ $transcolorindex = @imagecolortransparent($image);
+ if($transcolorindex >= 0 ) { //transparent color exists
+ $transcolor = @imagecolorsforindex($image, $transcolorindex);
+ $transcolorindex = @imagecolorallocate($newimg, $transcolor['red'], $transcolor['green'], $transcolor['blue']);
+ @imagefill($newimg, 0, 0, $transcolorindex);
+ @imagecolortransparent($newimg, $transcolorindex);
+ }else{ //filling with white
+ $whitecolorindex = @imagecolorallocate($newimg, 255, 255, 255);
+ @imagefill($newimg, 0, 0, $whitecolorindex);
+ }
+ }else{ //filling with white
+ $whitecolorindex = @imagecolorallocate($newimg, 255, 255, 255);
+ @imagefill($newimg, 0, 0, $whitecolorindex);
+ }
+ }
+
//try resampling first
if(function_exists("imagecopyresampled")){
if(!@imagecopyresampled($newimg, $image, 0, 0, 0, 0, $to_w, $to_h, $from_w, $from_h)) {