<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pacecode Blog &#187; image resizing using php</title>
	<atom:link href="http://www.pacecode.com/blog/tag/image-resizing-using-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pacecode.com/blog</link>
	<description>Tips, Scripts and More...</description>
	<lastBuildDate>Sat, 03 Dec 2011 09:45:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Problem with transparent image resizing? &#8211; PHP</title>
		<link>http://www.pacecode.com/blog/2008/12/03/problem-with-transparent-image-resizing/</link>
		<comments>http://www.pacecode.com/blog/2008/12/03/problem-with-transparent-image-resizing/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 17:33:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascripts]]></category>
		<category><![CDATA[php developers]]></category>
		<category><![CDATA[php scripts]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[animated image resize]]></category>
		<category><![CDATA[image resizing using php]]></category>
		<category><![CDATA[imagecreatetruecolor]]></category>
		<category><![CDATA[on the fly image resize]]></category>
		<category><![CDATA[open source image resize script]]></category>
		<category><![CDATA[transparent image resize]]></category>

		<guid isPermaLink="false">http://www.pacecode.com/blog/?p=88</guid>
		<description><![CDATA[You will get black background if you resize a transparent image. To fix it, You need set alpha channel imagecolorallocatealpha to 127. With imagecolorallocatealpha, it will allocate a color for an image. Usage: int imagecolorallocatealpha ( resource image, int red, int green, int blue, int alpha) From PHP manual: imagecolorallocatealpha() behaves identically to imagecolorallocate() with [...]]]></description>
			<content:encoded><![CDATA[<p>You will get black background if you resize a transparent image. To fix it, You need set alpha channel imagecolorallocatealpha to 127. With imagecolorallocatealpha, it will allocate a color for an image.</p>
<p><strong>Usage:</strong><br />
int imagecolorallocatealpha ( resource image, int red, int green, int blue, int alpha)</p>
<p><strong>From PHP manual:</strong><br />
imagecolorallocatealpha() behaves identically to imagecolorallocate() with the addition of the transparency parameter alpha which may have a value between 0 and 127. 0 indicates completely opaque while 127<br />
indicates completely transparent. Returns FALSE if the allocation failed.</p>
<p>Before using it, you must set to false the blending mode for an image and set true the flag to save full alpha channel information.</p>
<p><strong>Example:</strong></p>
<p>&lt;?</p>
<p>$newImg = imagecreatetruecolor($nWidth, $nHeight);</p>
<p>imagealphablending($newImg, false);</p>
<p>imagesavealpha($newImg,true);</p>
<p>$transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127);</p>
<p>imagefilledrectangle($newImg, 0, 0, $nWidth, $nHeight, $transparent);</p>
<p>imagecopyresampled($newImg, $im, 0, 0, 0, 0, $nWidth, $nHeight, $imgInfo[0], $imgInfo[1]);</p>
<p>?&gt;</p>
<p><strong>Another way to fix this issue:</strong></p>
<p><strong>phpThumb() </strong>- Resize images on the fly</p>
<p><strong>Description: </strong>phpThumb() uses the GD library  to create thumbnails from images (JPEG, PNG, GIF, BMP, etc) on the fly. The output size is configurable (can be larger or smaller than the source), and the source may be the entire image or only a portion of the original image.</p>
<p><strong>Download:</strong> <a href="http://phpthumb.sourceforge.net/phpThumb.zip">Download</a></p>
<p><strong>Site:</strong> <a href="http://phpthumb.sourceforge.net/" title="phpThumb - a php thumbnail generator" rel="mediabox[800 600]">phpThumb()</a></p>
<p><strong>Demo:</strong> <a href="http://phpthumb.sourceforge.net/demo/demo/phpThumb.demo.demo.php" title="phpThumb Demo" rel="mediabox[800 600]">Demo</a></p>
<p><strong>Installation: </strong></p>
<p>1. unzip the folder and upload the content into the server<br />
2. give the correct path of the phpThumb.php and image path as per the following syntax</p>
<p><strong>Resize Syntax:</strong><br />
&lt;img src="../phpThumb.php?src=images/watermark.png&amp;bg=FFFFFF&amp;f=png" alt=""&gt;<br />
&lt;img src="../phpThumb.php?src=images/watermark.png&amp;bg=FFFFFF&amp;f=gif" alt=""&gt;<br />
&lt;img src="../phpThumb.php?src=images/watermark.png&amp;bg=FFFFFF&amp;f=jpeg" alt=""&gt;</p>
<p>where the bg=FFFFFF represents the bg color of your transparent image.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pacecode.com/blog/2008/12/03/problem-with-transparent-image-resizing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

