<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Function to rotate image in PHP</title>
	<atom:link href="http://roshanbh.com.np/2008/06/rotate-image-in-php.html/feed" rel="self" type="application/rss+xml" />
	<link>http://roshanbh.com.np/2008/06/rotate-image-in-php.html</link>
	<description>Useful Tutorials, Scripts , Tips, and Resources for all PHP and Ajax beginners and experts .</description>
	<lastBuildDate>Tue, 07 Feb 2012 08:10:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: floor mats</title>
		<link>http://roshanbh.com.np/2008/06/rotate-image-in-php.html/comment-page-1#comment-5375</link>
		<dc:creator>floor mats</dc:creator>
		<pubDate>Wed, 21 Apr 2010 05:19:54 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/?p=120#comment-5375</guid>
		<description>The rotation is not working in IE. The image is getting freeze. Do not let me know how to solve this issue.</description>
		<content:encoded><![CDATA[<p>The rotation is not working in IE. The image is getting freeze. Do not let me know how to solve this issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: y2k2000</title>
		<link>http://roshanbh.com.np/2008/06/rotate-image-in-php.html/comment-page-1#comment-3698</link>
		<dc:creator>y2k2000</dc:creator>
		<pubDate>Tue, 24 Mar 2009 17:55:07 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/?p=120#comment-3698</guid>
		<description>Ty for the script.
Also I made some improvements  that i wish share with you:
- Fix GD version &gt;= 3
- Fix imagejpeg() : output according to original image format


gdVersion();
	if ($gd &gt;= 3) {
		$r = -$degreeOfRotation;
			if (!defined(&#039;MAGICK_PATH&#039;)) {
				define(&#039;MAGICK_PATH_FINAL&#039;, &#039;convert&#039;);
			} else if (strpos(strtolower(MAGICK_PATH), &#039;c:\\&#039;) !== false) {
				define(&#039;MAGICK_PATH_FINAL&#039;, &#039;&quot;&#039; . MAGICK_PATH . &#039;&quot;&#039;);	
			} else {
				define(&#039;MAGICK_PATH_FINAL&#039;, MAGICK_PATH);	
			}

		$cmd = MAGICK_PATH_FINAL . &quot; \&quot;$name\&quot; -rotate $r \&quot;$dest\&quot;&quot;;
		exec($cmd);
	} else {
		  $imageinfo=getimagesize($sourceFile);
		  switch($imageinfo[&#039;mime&#039;])
		  {
			case &quot;image/jpg&quot;:
				case &quot;image/jpeg&quot;:
					case &quot;image/pjpeg&quot;: //for IE
						$type = &quot;jpg&quot;;
						$src_img=imagecreatefromjpeg(&quot;$sourceFile&quot;);
			break;
			
			case &quot;image/gif&quot;:
				$type = &quot;gif&quot;;
				$src_img = imagecreatefromgif(&quot;$sourceFile&quot;);
			break;
			
			case &quot;image/png&quot;:
				case &quot;image/x-png&quot;: //for IE
					$type = &quot;png&quot;;
					$src_img = imagecreatefrompng(&quot;$sourceFile&quot;);
			break;
		  }
		  //rotate the image according to the spcified degree
		  $src_img = imagerotate($src_img, $degreeOfRotation, 0);
		  
		  //output the image to a file
			if ($type == &#039;png&#039;) {
				imagepng($src_img, $destImageName); 
			} elseif ($type == &#039;gif&#039;) {
				imagegif($src_img, $destImageName);
			} else {
				imagejpeg($src_img, $destImageName); 
			}
			
			imagedestroy($src_img);
			imagedestroy($destImageName);

}

}


?&gt;</description>
		<content:encoded><![CDATA[<p>Ty for the script.<br />
Also I made some improvements  that i wish share with you:<br />
- Fix GD version &gt;= 3<br />
- Fix imagejpeg() : output according to original image format</p>
<p>gdVersion();<br />
	if ($gd &gt;= 3) {<br />
		$r = -$degreeOfRotation;<br />
			if (!defined(&#8216;MAGICK_PATH&#8217;)) {<br />
				define(&#8216;MAGICK_PATH_FINAL&#8217;, &#8216;convert&#8217;);<br />
			} else if (strpos(strtolower(MAGICK_PATH), &#8216;c:\\&#8217;) !== false) {<br />
				define(&#8216;MAGICK_PATH_FINAL&#8217;, &#8216;&#8221;&#8216; . MAGICK_PATH . &#8216;&#8221;&#8216;);<br />
			} else {<br />
				define(&#8216;MAGICK_PATH_FINAL&#8217;, MAGICK_PATH);<br />
			}</p>
<p>		$cmd = MAGICK_PATH_FINAL . &#8221; \&#8221;$name\&#8221; -rotate $r \&#8221;$dest\&#8221;";<br />
		exec($cmd);<br />
	} else {<br />
		  $imageinfo=getimagesize($sourceFile);<br />
		  switch($imageinfo['mime'])<br />
		  {<br />
			case &#8220;image/jpg&#8221;:<br />
				case &#8220;image/jpeg&#8221;:<br />
					case &#8220;image/pjpeg&#8221;: //for IE<br />
						$type = &#8220;jpg&#8221;;<br />
						$src_img=imagecreatefromjpeg(&#8220;$sourceFile&#8221;);<br />
			break;</p>
<p>			case &#8220;image/gif&#8221;:<br />
				$type = &#8220;gif&#8221;;<br />
				$src_img = imagecreatefromgif(&#8220;$sourceFile&#8221;);<br />
			break;</p>
<p>			case &#8220;image/png&#8221;:<br />
				case &#8220;image/x-png&#8221;: //for IE<br />
					$type = &#8220;png&#8221;;<br />
					$src_img = imagecreatefrompng(&#8220;$sourceFile&#8221;);<br />
			break;<br />
		  }<br />
		  //rotate the image according to the spcified degree<br />
		  $src_img = imagerotate($src_img, $degreeOfRotation, 0);</p>
<p>		  //output the image to a file<br />
			if ($type == &#8216;png&#8217;) {<br />
				imagepng($src_img, $destImageName);<br />
			} elseif ($type == &#8216;gif&#8217;) {<br />
				imagegif($src_img, $destImageName);<br />
			} else {<br />
				imagejpeg($src_img, $destImageName);<br />
			}</p>
<p>			imagedestroy($src_img);<br />
			imagedestroy($destImageName);</p>
<p>}</p>
<p>}</p>
<p>?&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jules</title>
		<link>http://roshanbh.com.np/2008/06/rotate-image-in-php.html/comment-page-1#comment-1112</link>
		<dc:creator>Jules</dc:creator>
		<pubDate>Fri, 06 Jun 2008 11:53:18 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/?p=120#comment-1112</guid>
		<description>Thanks for this tip.
I would like to remind everyone that this process reduces the quality of the picture.
File 1 = 36.38 kB (37248 bytes)
File 2 = 7.56 kB (7746 bytes)
what a pity!</description>
		<content:encoded><![CDATA[<p>Thanks for this tip.<br />
I would like to remind everyone that this process reduces the quality of the picture.<br />
File 1 = 36.38 kB (37248 bytes)<br />
File 2 = 7.56 kB (7746 bytes)<br />
what a pity!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 2/7 queries in 0.149 seconds using disk: basic
Object Caching 221/221 objects using disk: basic

Served from: roshanbh.com.np @ 2012-02-08 21:59:05 -->
