<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="http://www.netlobo.com/commentsrss.php?aid=27" rel="self" type="application/rss+xml" />
		<title>Comments on: Resizing an Image Using PHP and the GD2 Library</title>
		<description>A PHP function that will resize your jpg images to any size you choose.</description>
		<link>http://www.netlobo.com/comments/php_image_resize_gd2</link>
		<language>en-us</language>
		<copyright>Copyright 2010, Netlobo.com</copyright>
		<lastBuildDate>Fri, 04 Jun 2010 07:57:17 GMT</lastBuildDate>
		<generator>Netlobo In-house RSS v1.4</generator>
		<item>
			<title>Steven</title>
			<description>I can't get the function to work. Its not saving as jpeg. Eg. when I set test.jpg as the destination it gets saved as testjpg (without the dot). How do I resolve this? Many thanks in advance</description>
			<link>http://www.netlobo.com/comments/php_image_resize_gd2#comment-556</link>
			<guid>http://www.netlobo.com/comments/php_image_resize_gd2#comment-556</guid>
			<pubDate>Thu, 03 Jun 2010 19:35:43 GMT</pubDate>
		</item>
		<item>
			<title>lcmichal</title>
			<description>thank you so much, great work :D very useful. </description>
			<link>http://www.netlobo.com/comments/php_image_resize_gd2#comment-544</link>
			<guid>http://www.netlobo.com/comments/php_image_resize_gd2#comment-544</guid>
			<pubDate>Sat, 24 Apr 2010 10:49:41 GMT</pubDate>
		</item>
		<item>
			<title>Hugo</title>
			<description>The same source with some refactoring :&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
function imageResize($source, $dest, $maxWidth, $maxHeight)
{
  $is = getimagesize($source);
  $fw = ($is[0] &amp;gt;= $is[1]) ? $maxWidth : $maxHeight;
  $fh = ($is[0] &amp;gt;= $is[1]) ? $maxHeight : $maxWidth;
  $orientation = ($is[0] &amp;gt;= $is[1]) ? 0 : 1;

  $iw = $is[0];
  $ih = $is[1];
  $t = 2;

  if ($is[0] &amp;gt; $fw || $is[1] &amp;gt; $fh)
  {
    if ($is[0] - $fw &amp;gt;= $is[1] - $fh)
    {
      $iw = $fw;
      $ih = ($fw / $is[0]) * $is[1];
    }
    else
    {
      $ih = $fh;
      $iw = ($ih / $is[1]) * $is[0];
    }
    
    $t = 1;
  }

  switch ($t)
  {
    case 1:
      $src = imagecreatefromjpeg($source);
      $dst = imagecreatetruecolor( $iw, $ih );
      imagecopyresampled($dst, $src, 0, 0, 0, 0, $iw, $ih, $is[0], $is[1]);
      return imagejpeg($dst, $dest, 90);
      break;
    case 2:
      return copy($source, $dest);
      break;
    default:
      return false;
      break;
  }
}
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
My 2 cents ;)</description>
			<link>http://www.netlobo.com/comments/php_image_resize_gd2#comment-525</link>
			<guid>http://www.netlobo.com/comments/php_image_resize_gd2#comment-525</guid>
			<pubDate>Wed, 10 Mar 2010 21:40:34 GMT</pubDate>
		</item>
		<item>
			<title>lobo235</title>
			<description>It would be similar to the function to resize jpgs but you would need to use different functions to read the png/gif image in before resizing it.</description>
			<link>http://www.netlobo.com/comments/php_image_resize_gd2#comment-489</link>
			<guid>http://www.netlobo.com/comments/php_image_resize_gd2#comment-489</guid>
			<pubDate>Thu, 19 Nov 2009 05:35:28 GMT</pubDate>
		</item>
		<item>
			<title>frann</title>
			<description>This is perfect - but what if the image to be resized is a gif or a png?</description>
			<link>http://www.netlobo.com/comments/php_image_resize_gd2#comment-488</link>
			<guid>http://www.netlobo.com/comments/php_image_resize_gd2#comment-488</guid>
			<pubDate>Wed, 18 Nov 2009 14:17:05 GMT</pubDate>
		</item>
		<item>
			<title>Mneil</title>
			<description>Perfect! Added a little functionality to my soon to come blog. Thanks for the script!</description>
			<link>http://www.netlobo.com/comments/php_image_resize_gd2#comment-352</link>
			<guid>http://www.netlobo.com/comments/php_image_resize_gd2#comment-352</guid>
			<pubDate>Thu, 06 Nov 2008 20:46:25 GMT</pubDate>
		</item>
		<item>
			<title>Robert</title>
			<description>Hello,&lt;br /&gt;
&lt;br /&gt;
Thanks for all of the info. Very helpful as I am new to PHP.&lt;br /&gt;
would like to use the resize code above with the GD library but I want to Replace the image with the new resized one.&lt;br /&gt;
&lt;br /&gt;
How might I alter your function above?&lt;br /&gt;
&lt;br /&gt;
Thanks in advance&lt;br /&gt;
&lt;br /&gt;
Robert</description>
			<link>http://www.netlobo.com/comments/php_image_resize_gd2#comment-329</link>
			<guid>http://www.netlobo.com/comments/php_image_resize_gd2#comment-329</guid>
			<pubDate>Tue, 16 Sep 2008 04:40:48 GMT</pubDate>
		</item>
		<item>
			<title>Vlad</title>
			<description>Thank you very much, it works just fine!</description>
			<link>http://www.netlobo.com/comments/php_image_resize_gd2#comment-324</link>
			<guid>http://www.netlobo.com/comments/php_image_resize_gd2#comment-324</guid>
			<pubDate>Sat, 06 Sep 2008 15:08:45 GMT</pubDate>
		</item>
		<item>
			<title>lobo235</title>
			<description>The forced width and forced height are measured in pixels. So if you want the resized image to fit in a 640x640 box you would pass the number 640 for both parameters. The source image and destination image should be passed in with either the full path or the path relative to the php script.&lt;br /&gt;
&lt;br /&gt;
Are you getting a specific error when you try to use the function?</description>
			<link>http://www.netlobo.com/comments/php_image_resize_gd2#comment-144</link>
			<guid>http://www.netlobo.com/comments/php_image_resize_gd2#comment-144</guid>
			<pubDate>Mon, 10 Dec 2007 19:18:11 GMT</pubDate>
		</item>
		<item>
			<title>ahhoi</title>
			<description>sounds very promising! can't get ir trunning though as I don't know how to &amp;quot;must pass in the forced width, forced height, source image, and destination image&amp;quot; in the right format (including path?). sorry, php newbie here ... thx fo any more comments!</description>
			<link>http://www.netlobo.com/comments/php_image_resize_gd2#comment-143</link>
			<guid>http://www.netlobo.com/comments/php_image_resize_gd2#comment-143</guid>
			<pubDate>Sat, 08 Dec 2007 22:07:46 GMT</pubDate>
		</item>
	</channel>
</rss>

<!-- pageGen: 0.1489 secs -->
<!-- memcache hits: 0 memcache misses: 2 -->