<?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: Manipulating Images using the PHP GD Library</title>
	<atom:link href="http://www.lateralcode.com/manipulating-images-using-the-php-gd-library/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lateralcode.com/manipulating-images-using-the-php-gd-library/</link>
	<description>A Blog Focused on Code and Technology</description>
	<lastBuildDate>Fri, 12 Mar 2010 15:09:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: G</title>
		<link>http://www.lateralcode.com/manipulating-images-using-the-php-gd-library/#comment-631</link>
		<dc:creator>G</dc:creator>
		<pubDate>Wed, 05 Aug 2009 16:12:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.lateralcode.com/?p=593#comment-631</guid>
		<description>After the image is resampled - using Imagecopyresampled, How do I save it to a different folder on the browser?
Lets say initial file is upload to folder A - after the image is resampled.. how do I move it to folder B - under same parent folder..
- This is what I have for now... 
$demoImage = getcwd().&quot;/demo_files/&quot;;
    $finalImage = getcwd().&quot;/Final/&quot;;
	$src = &quot;demo_files/&quot;.$_GET[&#039;pic&#039;];
	$img_r = imagecreatefromjpeg($src);
	$dst_r = ImageCreateTrueColor( $targ_w, $targ_h );

	imagecopyresampled($dst_r,$img_r,0,0,$_POST[&#039;x&#039;],$_POST[&#039;y&#039;],
	$targ_w,$targ_h,$_POST[&#039;w&#039;],$_POST[&#039;h&#039;]);
	header(&#039;Content-type: image/jpeg&#039;);
	imagejpeg($dst_r,null,$jpeg_quality);	
	copy($dst_r, $finalImage.$_GET[&#039;pic&#039;]);</description>
		<content:encoded><![CDATA[<p>After the image is resampled &#8211; using Imagecopyresampled, How do I save it to a different folder on the browser?<br />
Lets say initial file is upload to folder A &#8211; after the image is resampled.. how do I move it to folder B &#8211; under same parent folder..<br />
- This is what I have for now&#8230;<br />
$demoImage = getcwd().&#8221;/demo_files/&#8221;;<br />
    $finalImage = getcwd().&#8221;/Final/&#8221;;<br />
	$src = &#8220;demo_files/&#8221;.$_GET['pic'];<br />
	$img_r = imagecreatefromjpeg($src);<br />
	$dst_r = ImageCreateTrueColor( $targ_w, $targ_h );</p>
<p>	imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],<br />
	$targ_w,$targ_h,$_POST['w'],$_POST['h']);<br />
	header(&#8216;Content-type: image/jpeg&#8217;);<br />
	imagejpeg($dst_r,null,$jpeg_quality);<br />
	copy($dst_r, $finalImage.$_GET['pic']);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin</title>
		<link>http://www.lateralcode.com/manipulating-images-using-the-php-gd-library/#comment-621</link>
		<dc:creator>Justin</dc:creator>
		<pubDate>Mon, 27 Jul 2009 20:01:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.lateralcode.com/?p=593#comment-621</guid>
		<description>I got it. the problem is. you have to set your max width and height.</description>
		<content:encoded><![CDATA[<p>I got it. the problem is. you have to set your max width and height.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin</title>
		<link>http://www.lateralcode.com/manipulating-images-using-the-php-gd-library/#comment-620</link>
		<dc:creator>Justin</dc:creator>
		<pubDate>Mon, 27 Jul 2009 19:58:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.lateralcode.com/?p=593#comment-620</guid>
		<description>So here is my code:

&lt;?php
	$src = imagecreatefromjpeg( &#039;sunburst.jpg&#039; );

	# Calculate width and height based on larger dimension
	if ( ($oldW = imagesx($src)) 

This works perfectly. Like the others Im trying to create a thumbnail exactly 100X100. When I replace what you told me to above. This is what I have now.


I see that $dst doesnt exist anymore, so even if I get rid of those and replace with 	

imagejpeg( $new );
imagedestroy( $src );
imagedestroy( $new );

still does not work. do you by chance see where im going wrong.</description>
		<content:encoded><![CDATA[<p>So here is my code:</p>
<p>&lt;?php<br />
	$src = imagecreatefromjpeg( &#8217;sunburst.jpg&#8217; );</p>
<p>	# Calculate width and height based on larger dimension<br />
	if ( ($oldW = imagesx($src)) </p>
<p>This works perfectly. Like the others Im trying to create a thumbnail exactly 100X100. When I replace what you told me to above. This is what I have now.</p>
<p>I see that $dst doesnt exist anymore, so even if I get rid of those and replace with 	</p>
<p>imagejpeg( $new );<br />
imagedestroy( $src );<br />
imagedestroy( $new );</p>
<p>still does not work. do you by chance see where im going wrong.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deca</title>
		<link>http://www.lateralcode.com/manipulating-images-using-the-php-gd-library/#comment-417</link>
		<dc:creator>Deca</dc:creator>
		<pubDate>Sat, 28 Mar 2009 18:06:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.lateralcode.com/?p=593#comment-417</guid>
		<description>Great! Thanks,

works like a charm!</description>
		<content:encoded><![CDATA[<p>Great! Thanks,</p>
<p>works like a charm!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick Lin</title>
		<link>http://www.lateralcode.com/manipulating-images-using-the-php-gd-library/#comment-415</link>
		<dc:creator>Patrick Lin</dc:creator>
		<pubDate>Sat, 28 Mar 2009 16:23:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.lateralcode.com/?p=593#comment-415</guid>
		<description>Hello Deca,

The part you need to replace in Simple Picture Gallery is this:

&lt;pre&gt;
	if ( ($oldW = imagesx($src)) &lt; ($oldH = imagesy($src)) ) {
		$newW = $oldW * ($max_width / $oldH);
		$newH = $max_height;
	} else {
		$newW = $max_width;
		$newH = $oldH * ($max_height / $oldW);
	}
	$new = imagecreatetruecolor($newW, $newH);
	imagecopyresampled($new, $src, 0, 0, 0, 0, $newW, $newH, $oldW, $oldH);
&lt;/pre&gt;

What you would want to replace it with is this:

&lt;/pre&gt;&lt;pre&gt;
	$new = imagecreate( $max_width, $max_height ); # Create a blank target image

	# Calculate top-left coordinates of the source by getting the
	# center coordinates and then subtracting half the target width
	$src_x = ( imagesx( $src ) / 2 ) - ( $max_width / 2 );
	$src_y = ( imagesy( $src ) / 2 ) - ( $max_height / 2 );

	imagecopy( $new, $src, 0, 0, $src_x, $src_y, $max_width, $max_height );
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Hello Deca,</p>
<p>The part you need to replace in Simple Picture Gallery is this:</p>
<pre>
	if ( ($oldW = imagesx($src)) < ($oldH = imagesy($src)) ) {
		$newW = $oldW * ($max_width / $oldH);
		$newH = $max_height;
	} else {
		$newW = $max_width;
		$newH = $oldH * ($max_height / $oldW);
	}
	$new = imagecreatetruecolor($newW, $newH);
	imagecopyresampled($new, $src, 0, 0, 0, 0, $newW, $newH, $oldW, $oldH);
</pre>
<p>What you would want to replace it with is this:</p>
</pre>
<pre>
	$new = imagecreate( $max_width, $max_height ); # Create a blank target image

	# Calculate top-left coordinates of the source by getting the
	# center coordinates and then subtracting half the target width
	$src_x = ( imagesx( $src ) / 2 ) - ( $max_width / 2 );
	$src_y = ( imagesy( $src ) / 2 ) - ( $max_height / 2 );

	imagecopy( $new, $src, 0, 0, $src_x, $src_y, $max_width, $max_height );
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deca</title>
		<link>http://www.lateralcode.com/manipulating-images-using-the-php-gd-library/#comment-413</link>
		<dc:creator>Deca</dc:creator>
		<pubDate>Sat, 28 Mar 2009 12:44:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.lateralcode.com/?p=593#comment-413</guid>
		<description>Great tutorials!

If been reading and trying your tutorial &quot;Create a Simple Picture Gallery using PHP&quot; and just like kloc i want my thumbnails to be square/cropped instead of there max height/width to be 100.

So I think i would be wanting it like the Imagecopy, but I can&#039;t seem to make it work in the Simple Picture Gallery, I&#039;m not very good at PHP.</description>
		<content:encoded><![CDATA[<p>Great tutorials!</p>
<p>If been reading and trying your tutorial &#8220;Create a Simple Picture Gallery using PHP&#8221; and just like kloc i want my thumbnails to be square/cropped instead of there max height/width to be 100.</p>
<p>So I think i would be wanting it like the Imagecopy, but I can&#8217;t seem to make it work in the Simple Picture Gallery, I&#8217;m not very good at PHP.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 網站製作學習誌 &#187; [Web] 連結分享</title>
		<link>http://www.lateralcode.com/manipulating-images-using-the-php-gd-library/#comment-410</link>
		<dc:creator>網站製作學習誌 &#187; [Web] 連結分享</dc:creator>
		<pubDate>Fri, 27 Mar 2009 20:21:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.lateralcode.com/?p=593#comment-410</guid>
		<description>[...] Manipulating Images using the PHP GD Library [...]</description>
		<content:encoded><![CDATA[<p>[...] Manipulating Images using the PHP GD Library [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: busykid</title>
		<link>http://www.lateralcode.com/manipulating-images-using-the-php-gd-library/#comment-376</link>
		<dc:creator>busykid</dc:creator>
		<pubDate>Mon, 23 Mar 2009 08:14:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.lateralcode.com/?p=593#comment-376</guid>
		<description>Tnx,</description>
		<content:encoded><![CDATA[<p>Tnx,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: carlo</title>
		<link>http://www.lateralcode.com/manipulating-images-using-the-php-gd-library/#comment-355</link>
		<dc:creator>carlo</dc:creator>
		<pubDate>Wed, 18 Mar 2009 08:31:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.lateralcode.com/?p=593#comment-355</guid>
		<description>very good article! Thanks
Carlo</description>
		<content:encoded><![CDATA[<p>very good article! Thanks<br />
Carlo</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Max</title>
		<link>http://www.lateralcode.com/manipulating-images-using-the-php-gd-library/#comment-342</link>
		<dc:creator>Max</dc:creator>
		<pubDate>Tue, 17 Mar 2009 14:54:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.lateralcode.com/?p=593#comment-342</guid>
		<description>Great tutorials on Your blog!! Thank You! Always useful!!</description>
		<content:encoded><![CDATA[<p>Great tutorials on Your blog!! Thank You! Always useful!!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
