Transparents thumbs [Flatpress]

English

I’ve added some code to thumb plugin that allows the get transparent thumbs with GIFs and PNGs files.

I’ve taken this code from a comment of the imagecopyresampled PHP function.

Open fp-plugins/thumb/plugin.thumb.php with a text editor and replace:

	$scaled = imagecreatetruecolor($new_width, $new_height);
	imagecopyresampled($scaled, $image, 0, 0, 0, 0, $new_width, $new_height, $infos<sup><a id="entry110824-114301-rel-0" href="#entry110824-114301-fn-0" title="Note 0">0</a></sup>, $infos<sup><a id="entry110824-114301-rel-1" href="#entry110824-114301-fn-1" title="Note 1">1</a></sup>);

with

	$scaled = imagecreatetruecolor($new_width, $new_height);

	/*
	 * If gif or png preserve the alpha channel
	 *
	 * Added by Piero VDFN
	 * Kudos to http://www.php.net/manual/en/function.imagecopyresampled.php#104028
	 */
	if($infos<sup><a id="entry110824-114301-rel-2" href="#entry110824-114301-fn-2" title="Note 2">2</a></sup>==1 &#124;&#124; $infos<sup><a id="entry110824-114301-rel-2" href="#entry110824-114301-fn-2" title="Note 2">2</a></sup>==3) {
		imagecolortransparent($scaled, imagecolorallocatealpha($scaled, 0, 0, 0, 127));
		imagealphablending($scaled, false);
		imagesavealpha($scaled, true);
		$output=$infos<sup><a id="entry110824-114301-rel-2" href="#entry110824-114301-fn-2" title="Note 2">2</a></sup>==3 ? 'png' : 'gif';
	} else {
		$output='jpg';
	}

	imagecopyresampled($scaled, $image, 0, 0, 0, 0, $new_width, $new_height, $infos<sup><a id="entry110824-114301-rel-0" href="#entry110824-114301-fn-0" title="Note 0">0</a></sup>, $infos<sup><a id="entry110824-114301-rel-1" href="#entry110824-114301-fn-1" title="Note 1">1</a></sup>);

Now, replace some lines belove imagejpeg($scaled, $thumbpath); with: … [Leggi il resto]