<?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: PHP: Resize Image and Store to File</title>
	<atom:link href="http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html</link>
	<description>Just another dumbass webmaster, goofing around...</description>
	<lastBuildDate>Wed, 08 Feb 2012 09:57:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: PHP: Get Mime Type of a File (and Encoding)</title>
		<link>http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html/comment-page-1#comment-16358</link>
		<dc:creator>PHP: Get Mime Type of a File (and Encoding)</dc:creator>
		<pubDate>Sun, 25 Dec 2011 04:24:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html#comment-16358</guid>
		<description>[...] out if the extension is enabled with the code outlined in the beginning part of the resize image in PHP [...]</description>
		<content:encoded><![CDATA[<p>[...] out if the extension is enabled with the code outlined in the beginning part of the resize image in PHP [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Clayton</title>
		<link>http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html/comment-page-1#comment-15679</link>
		<dc:creator>Mike Clayton</dc:creator>
		<pubDate>Mon, 07 Nov 2011 20:25:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html#comment-15679</guid>
		<description>Great script. By far the quickest-to-use script for image resizing I have found yet!!!!!</description>
		<content:encoded><![CDATA[<p>Great script. By far the quickest-to-use script for image resizing I have found yet!!!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kieuw-</title>
		<link>http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html/comment-page-1#comment-15511</link>
		<dc:creator>Kieuw-</dc:creator>
		<pubDate>Sat, 27 Aug 2011 12:06:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html#comment-15511</guid>
		<description>Thanks all the way from Puerto Rico! It is awesome! Thanks!</description>
		<content:encoded><![CDATA[<p>Thanks all the way from Puerto Rico! It is awesome! Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: WILLIAMPGH</title>
		<link>http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html/comment-page-1#comment-14358</link>
		<dc:creator>WILLIAMPGH</dc:creator>
		<pubDate>Sun, 20 Mar 2011 17:53:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html#comment-14358</guid>
		<description>You need to set the file folder in windows to share to upload files to it. If the folder is not to set to share on your system, you can not upload files cause the file folder is set to read only if you do not share the folder. Just a heads up. =)</description>
		<content:encoded><![CDATA[<p>You need to set the file folder in windows to share to upload files to it. If the folder is not to set to share on your system, you can not upload files cause the file folder is set to read only if you do not share the folder. Just a heads up. =)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: EricC</title>
		<link>http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html/comment-page-1#comment-14267</link>
		<dc:creator>EricC</dc:creator>
		<pubDate>Wed, 23 Feb 2011 18:41:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html#comment-14267</guid>
		<description>Nice, and far better with the switch cases added by Greg.
Plus, this code is more or less useless for me, the old file being overwritten by the new one :
if (file_exists($targetFile)) {
	unlink($targetFile);
}</description>
		<content:encoded><![CDATA[<p>Nice, and far better with the switch cases added by Greg.<br />
Plus, this code is more or less useless for me, the old file being overwritten by the new one :<br />
if (file_exists($targetFile)) {<br />
	unlink($targetFile);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kim Hoe</title>
		<link>http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html/comment-page-1#comment-11348</link>
		<dc:creator>Kim Hoe</dc:creator>
		<pubDate>Wed, 08 Dec 2010 05:51:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html#comment-11348</guid>
		<description>Sorry, I think the copy and paste working well.

Here is the script that I use to call the function:

$work = new ImgResizer(&#039;104246094.jpg&#039;);
$work -&gt; resize(400, &#039;104246094_400.jpg&#039;);</description>
		<content:encoded><![CDATA[<p>Sorry, I think the copy and paste working well.</p>
<p>Here is the script that I use to call the function:</p>
<p>$work = new ImgResizer(&#8217;104246094.jpg&#8217;);<br />
$work -&gt; resize(400, &#8217;104246094_400.jpg&#8217;);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kim Hoe</title>
		<link>http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html/comment-page-1#comment-11347</link>
		<dc:creator>Kim Hoe</dc:creator>
		<pubDate>Wed, 08 Dec 2010 04:36:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html#comment-11347</guid>
		<description>Hi,

I couldn&#039;t get this work. Please can you check for me? No Error is given.

 originalFile = $originalFile;
		}
		public function resize($newWidth, $targetFile) {
			if (empty($newWidth) &#124;&#124; empty($targetFile)) {
				return false;
			}
			$src = imagecreatefromjpeg($this -&gt; originalFile);
			list($width, $height) = getimagesize($this -&gt; originalFile);
			$newHeight = ($height / $width) * $newWidth;
			$tmp = imagecreatetruecolor($newWidth, $newHeight);
			imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
			if (file_exists($targetFile)) {
				unlink($targetFile);
			}
			imagejpeg($tmp, $targetFile, 85); // 85 is my choice, make it between 0 – 100 for output image quality with 100 being the most luxurious
		}
	}

?&gt;


 resize(400, &#039;104246094_400.jpg&#039;);
?&gt;</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I couldn&#8217;t get this work. Please can you check for me? No Error is given.</p>
<p> originalFile = $originalFile;<br />
		}<br />
		public function resize($newWidth, $targetFile) {<br />
			if (empty($newWidth) || empty($targetFile)) {<br />
				return false;<br />
			}<br />
			$src = imagecreatefromjpeg($this -&gt; originalFile);<br />
			list($width, $height) = getimagesize($this -&gt; originalFile);<br />
			$newHeight = ($height / $width) * $newWidth;<br />
			$tmp = imagecreatetruecolor($newWidth, $newHeight);<br />
			imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);<br />
			if (file_exists($targetFile)) {<br />
				unlink($targetFile);<br />
			}<br />
			imagejpeg($tmp, $targetFile, 85); // 85 is my choice, make it between 0 – 100 for output image quality with 100 being the most luxurious<br />
		}<br />
	}</p>
<p>?&gt;</p>
<p> resize(400, &#8217;104246094_400.jpg&#8217;);<br />
?&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yang Yang</title>
		<link>http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html/comment-page-1#comment-10576</link>
		<dc:creator>Yang Yang</dc:creator>
		<pubDate>Wed, 28 Jul 2010 00:28:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html#comment-10576</guid>
		<description>Try changing the single quotes to double quotes:

private $originalFile = &quot;uploads/thumb/$img&quot;;</description>
		<content:encoded><![CDATA[<p>Try changing the single quotes to double quotes:</p>
<p>private $originalFile = &#8220;uploads/thumb/$img&#8221;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html/comment-page-1#comment-10572</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Tue, 27 Jul 2010 03:03:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html#comment-10572</guid>
		<description>First off, thank you for a wonderful class.

Second: I can&#039;t seem to get it to work when using a $variable for the original image name.

e.g. private $originalFile = &#039;uploads/thumb/$img&#039;;
where $img = &#039;asdf.jpg&#039;;

Any pointers?</description>
		<content:encoded><![CDATA[<p>First off, thank you for a wonderful class.</p>
<p>Second: I can&#8217;t seem to get it to work when using a $variable for the original image name.</p>
<p>e.g. private $originalFile = &#8216;uploads/thumb/$img&#8217;;<br />
where $img = &#8216;asdf.jpg&#8217;;</p>
<p>Any pointers?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yang Yang</title>
		<link>http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html/comment-page-1#comment-9877</link>
		<dc:creator>Yang Yang</dc:creator>
		<pubDate>Thu, 13 May 2010 14:42:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html#comment-9877</guid>
		<description>It feels so great to have helped people like you, Josep. :)</description>
		<content:encoded><![CDATA[<p>It feels so great to have helped people like you, Josep. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josep</title>
		<link>http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html/comment-page-1#comment-9873</link>
		<dc:creator>Josep</dc:creator>
		<pubDate>Wed, 12 May 2010 17:11:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html#comment-9873</guid>
		<description>Thank you very much Yang Yang for this class, 

I was searching on Google one easy method for image resizing with PHP and, all other that I found are very extensive and complicated.

Thanks for your contribution to the PHP world and greetings from Spain!

Josep Crespo.</description>
		<content:encoded><![CDATA[<p>Thank you very much Yang Yang for this class, </p>
<p>I was searching on Google one easy method for image resizing with PHP and, all other that I found are very extensive and complicated.</p>
<p>Thanks for your contribution to the PHP world and greetings from Spain!</p>
<p>Josep Crespo.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yang Yang</title>
		<link>http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html/comment-page-1#comment-9795</link>
		<dc:creator>Yang Yang</dc:creator>
		<pubDate>Mon, 19 Apr 2010 07:55:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html#comment-9795</guid>
		<description>Thanks, Greg. That&#039;s a nice upgrade to the class!</description>
		<content:encoded><![CDATA[<p>Thanks, Greg. That&#8217;s a nice upgrade to the class!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg</title>
		<link>http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html/comment-page-1#comment-9794</link>
		<dc:creator>Greg</dc:creator>
		<pubDate>Sun, 18 Apr 2010 20:13:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html#comment-9794</guid>
		<description>Excellent coding. Did the same, took the coding straight from the page, and it worked flawlessly.

I did a bit of modification though that might help someone.

Added to: public function resize($newWidth, $targetFile, $ext)

This is a previously tested string that could be &#039;jpg&#039;, &#039;gif&#039;, or &#039;png&#039;.

Then I replaced the one imagefromjpeg with:
switch ($ext) {
		case &quot;jpg&quot;:
		$src = imagecreatefromjpeg($this -&gt; originalFile);
		break;
		case &quot;gif&quot;:
		$src = ImageCreateFromGif($this -&gt; originalFile);
		break;
		case &quot;png&quot;:
		$src = ImageCreateFrompng($this -&gt; originalFile);
		break;
		}

And lastly, replaced the imagejpeg() with:

switch ($ext) {
		case &quot;jpg&quot;:
		imagejpeg($tmp, $targetFile, 80);
		break;
		case &quot;gif&quot;:
		imagegif($tmp, $targetFile);
		break;
		case &quot;png&quot;:
		imagepng($tmp, $targetFile, 8);
		break;
		}

So far, testing has worked well with all three types of files. Obviously it&#039;ll break some, like animated Gifs, but given my application that wasn&#039;t a deal breaker.

Thanks Yang!</description>
		<content:encoded><![CDATA[<p>Excellent coding. Did the same, took the coding straight from the page, and it worked flawlessly.</p>
<p>I did a bit of modification though that might help someone.</p>
<p>Added to: public function resize($newWidth, $targetFile, $ext)</p>
<p>This is a previously tested string that could be &#8216;jpg&#8217;, &#8216;gif&#8217;, or &#8216;png&#8217;.</p>
<p>Then I replaced the one imagefromjpeg with:<br />
switch ($ext) {<br />
		case &#8220;jpg&#8221;:<br />
		$src = imagecreatefromjpeg($this -&gt; originalFile);<br />
		break;<br />
		case &#8220;gif&#8221;:<br />
		$src = ImageCreateFromGif($this -&gt; originalFile);<br />
		break;<br />
		case &#8220;png&#8221;:<br />
		$src = ImageCreateFrompng($this -&gt; originalFile);<br />
		break;<br />
		}</p>
<p>And lastly, replaced the imagejpeg() with:</p>
<p>switch ($ext) {<br />
		case &#8220;jpg&#8221;:<br />
		imagejpeg($tmp, $targetFile, 80);<br />
		break;<br />
		case &#8220;gif&#8221;:<br />
		imagegif($tmp, $targetFile);<br />
		break;<br />
		case &#8220;png&#8221;:<br />
		imagepng($tmp, $targetFile, 8);<br />
		break;<br />
		}</p>
<p>So far, testing has worked well with all three types of files. Obviously it&#8217;ll break some, like animated Gifs, but given my application that wasn&#8217;t a deal breaker.</p>
<p>Thanks Yang!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yang Yang</title>
		<link>http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html/comment-page-1#comment-8922</link>
		<dc:creator>Yang Yang</dc:creator>
		<pubDate>Wed, 17 Mar 2010 07:29:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html#comment-8922</guid>
		<description>Thank you for your compliments, Jillian!</description>
		<content:encoded><![CDATA[<p>Thank you for your compliments, Jillian!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jillian</title>
		<link>http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html/comment-page-1#comment-8897</link>
		<dc:creator>Jillian</dc:creator>
		<pubDate>Tue, 16 Mar 2010 19:15:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.kavoir.com/2009/01/php-resize-image-and-store-to-file.html#comment-8897</guid>
		<description>This is a beautiful class. Most of the time when I take code from the web, it takes a while to debug, but your stuff worked without any modification. Thanks for posting this!</description>
		<content:encoded><![CDATA[<p>This is a beautiful class. Most of the time when I take code from the web, it takes a while to debug, but your stuff worked without any modification. Thanks for posting this!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

