<?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; animated image resize</title>
	<atom:link href="http://www.pacecode.com/blog/tag/animated-image-resize/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pacecode.com/blog</link>
	<description>Tips,Ideas, Free scripts and more...</description>
	<lastBuildDate>Sat, 24 Apr 2010 16:39:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<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>Raja MM</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 the addition of the [...]]]></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=&#8221;../phpThumb.php?src=images/watermark.png&amp;bg=FFFFFF&amp;f=png&#8221; alt=&#8221;"&gt;<br />
&lt;img src=&#8221;../phpThumb.php?src=images/watermark.png&amp;bg=FFFFFF&amp;f=gif&#8221; alt=&#8221;"&gt;<br />
&lt;img src=&#8221;../phpThumb.php?src=images/watermark.png&amp;bg=FFFFFF&amp;f=jpeg&#8221; alt=&#8221;"&gt;</p>
<p>where the bg=FFFFFF represents the bg color of your transparent image.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Share this post</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fwww.pacecode.com%2Fblog%2F2008%2F12%2F03%2Fproblem-with-transparent-image-resizing%2F&amp;submitHeadline=Problem+with+transparent+image+resizing%3F+%26%238211%3B+PHP&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.pacecode.com/blog/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.pacecode.com%2Fblog%2F2008%2F12%2F03%2Fproblem-with-transparent-image-resizing%2F&amp;title=Problem+with+transparent+image+resizing%3F+%26%238211%3B+PHP" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.pacecode.com/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.pacecode.com%2Fblog%2F2008%2F12%2F03%2Fproblem-with-transparent-image-resizing%2F&amp;title=Problem+with+transparent+image+resizing%3F+%26%238211%3B+PHP" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.pacecode.com/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.pacecode.com%2Fblog%2F2008%2F12%2F03%2Fproblem-with-transparent-image-resizing%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.pacecode.com/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.pacecode.com%2Fblog%2F2008%2F12%2F03%2Fproblem-with-transparent-image-resizing%2F&amp;title=Problem+with+transparent+image+resizing%3F+%26%238211%3B+PHP" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.pacecode.com/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fwww.pacecode.com%2Fblog%2F2008%2F12%2F03%2Fproblem-with-transparent-image-resizing%2F&amp;bm_description=Problem+with+transparent+image+resizing%3F+%26%238211%3B+PHP" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.pacecode.com/blog/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.pacecode.com%2Fblog%2F2008%2F12%2F03%2Fproblem-with-transparent-image-resizing%2F&amp;T=Problem+with+transparent+image+resizing%3F+%26%238211%3B+PHP" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.pacecode.com/blog/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.pacecode.com%2Fblog%2F2008%2F12%2F03%2Fproblem-with-transparent-image-resizing%2F&amp;title=Problem+with+transparent+image+resizing%3F+%26%238211%3B+PHP" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.pacecode.com/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.pacecode.com%2Fblog%2F2008%2F12%2F03%2Fproblem-with-transparent-image-resizing%2F&amp;title=Problem+with+transparent+image+resizing%3F+%26%238211%3B+PHP" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.pacecode.com/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.pacecode.com%2Fblog%2F2008%2F12%2F03%2Fproblem-with-transparent-image-resizing%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.pacecode.com/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fwww.pacecode.com%2Fblog%2F2008%2F12%2F03%2Fproblem-with-transparent-image-resizing%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://www.pacecode.com/blog/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Problem+with+transparent+image+resizing%3F+%26%238211%3B+PHP+@+http%3A%2F%2Fwww.pacecode.com%2Fblog%2F2008%2F12%2F03%2Fproblem-with-transparent-image-resizing%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.pacecode.com/blog/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.pacecode.com%2Fblog%2F2008%2F12%2F03%2Fproblem-with-transparent-image-resizing%2F&amp;t=Problem+with+transparent+image+resizing%3F+%26%238211%3B+PHP" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.pacecode.com/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></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>
