protected function normalizeGdResource($resource)
    {
        if(imageistruecolor($resource))
        {
            imagesavealpha($resource, TRUE);

            return $resource;
        }

        $width  = imagesx($resource);
        $height = imagesy($resource);

        $trueColor = imagecreatetruecolor($width, $height);

        imagealphablending($trueColor, FALSE);

        $transparent = imagecolorallocatealpha($trueColor, 255, 255, 255, 127);

        imagefilledrectangle($trueColor, 0, 0, $width, $height, $transparent);
        imagealphablending($trueColor, TRUE);

        imagecopy($trueColor, $resource, 0, 0, 0, 0, $width, $height);
        imagedestroy($resource);

        imagesavealpha($trueColor, TRUE);

        return $trueColor;
    }