Advertisement
Guest User

kerphi

a guest
Jul 18th, 2010
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.47 KB | None | 0 0
  1. --- library/core/class.uploadimage.php.orig     2010-07-18 13:01:24.000000000 +0200
  2. +++ library/core/class.uploadimage.php  2010-07-18 13:24:30.000000000 +0200
  3. @@ -137,10 +137,24 @@
  4.           throw new Exception(sprintf(T('You cannot save images of this type (%s).'), $Type));
  5.        
  6.        // Create a new image from the raw source
  7. -      if (function_exists('imagecreatetruecolor'))
  8. +      if (function_exists('imagecreatetruecolor')) {
  9.           $TargetImage = imagecreatetruecolor($Width, $Height);    // Only exists if GD2 is installed
  10. -      else
  11. +
  12. +         // define the background color (white or transparent)
  13. +         imagesavealpha($TargetImage, true);
  14. +         imagealphablending($TargetImage, true);
  15. +         if ($OutputType == 'png') {
  16. +            // background color is transparent
  17. +            $bg_color = imagecolortransparent($TargetImage, imagecolorallocatealpha($TargetImage, 0, 0, 0, 127)); // transparent
  18. +            imagesavealpha($TargetImage, true);
  19. +         } else {
  20. +            // background color is white
  21. +            $bg_color = imagecolorallocate($TargetImage, 255, 255, 255);
  22. +         }
  23. +         imagefill($TargetImage, 0, 0, $bg_color);
  24. +      } else {
  25.           $TargetImage = imagecreate($Width, $Height);             // Always exists if any GD is installed
  26. +      }
  27.          
  28.        imagecopyresampled($TargetImage, $SourceImage, 0, 0, $XCoord, $YCoord, $Width, $Height, $WidthSource, $HeightSource);
  29.        imagedestroy($SourceImage);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement