GdThumb::preserveAlpha PHP Method

preserveAlpha() protected method

Alpha / transparency will not be preserved if the appropriate options are set to false. Also, the GIF transparency is pretty skunky (the results aren't awesome), but it works like a champ... that's the nature of GIFs tho, so no huge surprise. This functionality was originally suggested by commenter Aimi (no links / site provided) - Thanks! :)
protected preserveAlpha ( )
    protected function preserveAlpha()
    {
        if ($this->format == 'PNG' && $this->options['preserveAlpha'] === true) {
            imagealphablending($this->workingImage, false);
            $colorTransparent = imagecolorallocatealpha($this->workingImage, $this->options['alphaMaskColor'][0], $this->options['alphaMaskColor'][1], $this->options['alphaMaskColor'][2], 0);
            imagefill($this->workingImage, 0, 0, $colorTransparent);
            imagesavealpha($this->workingImage, true);
        }
        // preserve transparency in GIFs... this is usually pretty rough tho
        if ($this->format == 'GIF' && $this->options['preserveTransparency'] === true) {
            $colorTransparent = imagecolorallocate($this->workingImage, $this->options['transparencyMaskColor'][0], $this->options['transparencyMaskColor'][1], $this->options['transparencyMaskColor'][2]);
            imagecolortransparent($this->workingImage, $colorTransparent);
            imagetruecolortopalette($this->workingImage, true, 256);
        }
    }