hello
I tried to add a logo in the society panel but i only got a full black image. I understood that the problem was coming from the transparency of the png logo.
I checked the SimpleGdImage.class.php and saw that there was no support for transparency in the scale function. After some research and test here is the patch.
The file is locate into opengoo/library/simplegd/classes
The original version : Line 341 to 347
if($this->getImageType() == IMAGETYPE_GIF) {
$new_resource = imagecreate($new_width, $new_height);
} else {
$new_resource = imagecreatetruecolor($new_width, $new_height);
} // if
imagecopyresampled($new_resource, $this->resource, 0, 0, 0, 0, $new_width, $new_height, $this->getWidth(), $this->getHeight());
And now it became
if($this->getImageType() == IMAGETYPE_GIF) {
$new_resource = imagecreate($new_width, $new_height);
$originaltransparentcolor = imagecolortransparent( $this->resource );
if(
$originaltransparentcolor >= 0 // -1 for opaque image
&& $originaltransparentcolor < imagecolorstotal( $this->resource )
// for animated GIF, imagecolortransparent will return a color index larger
// than total colors, in this case the image is treated as opaque ( actually
// it is opaque )
) {
$transparentcolor = imagecolorsforindex( $this->resource, $originaltransparentcolor );
$newtransparentcolor = imagecolorallocate($new_resource,$transparentcolor['red'],$transparentcolor['green'],
$transparentcolor['blue']);
// for true color image, we must fill the background manually
imagefill( $new_resource, 0, 0, $newtransparentcolor );
// assign the transparent color in the thumbnail image
imagecolortransparent( $new_resource, $newtransparentcolor );
}
} else {
$new_resource = imagecreatetruecolor($new_width, $new_height);
imagealphablending($new_resource, false);
imagesavealpha($new_resource, true);
} // if
imagecopyresampled($new_resource, $this->resource, 0, 0, 0, 0, $new_width, $new_height, $this->getWidth(), $this->getHeight());
The part for the gestion of the transparency for gif came from
http://be.php.net/manual/fr/function.imagecopyresized.php#76648 and seems to work with animated gif but i didn't tried.
This version has been tested with jpg, png with transparency, png without, gif with transparency and without.
Thanks for a so cool program.
I don't know were to put it so i link here my version of SimpleGdImage.class.php