<?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: Create a Simple Picture Gallery using PHP</title>
	<atom:link href="http://www.lateralcode.com/create-a-simple-picture-gallery-using-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lateralcode.com/create-a-simple-picture-gallery-using-php/</link>
	<description>A Web Development Blog Focused on Code and Technology</description>
	<lastBuildDate>Thu, 07 Jul 2011 20:22:31 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
	<item>
		<title>By: HBK</title>
		<link>http://www.lateralcode.com/create-a-simple-picture-gallery-using-php/#comment-32001</link>
		<dc:creator>HBK</dc:creator>
		<pubDate>Thu, 23 Jun 2011 13:19:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.lateralcode.com/?p=569#comment-32001</guid>
		<description>its nice</description>
		<content:encoded><![CDATA[<p>its nice</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Banderaz</title>
		<link>http://www.lateralcode.com/create-a-simple-picture-gallery-using-php/#comment-23465</link>
		<dc:creator>Banderaz</dc:creator>
		<pubDate>Mon, 11 Apr 2011 19:06:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.lateralcode.com/?p=569#comment-23465</guid>
		<description>Hi,
Great script!
I just want it to read the pictures from a different folder.
Can&#039;t get it to work. Anyone did that?
I got the thumbnails to be show, when the full-size pictures are in a different folder, by changing:
if ( $handle = opendir(&quot;.&quot;) ) {
to
if ( $handle = opendir(&quot;myimages/&quot;) ) {
But stuck after that :(
Any help would be great!

Any chance of putting a comment under each picture?</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Great script!<br />
I just want it to read the pictures from a different folder.<br />
Can&#8217;t get it to work. Anyone did that?<br />
I got the thumbnails to be show, when the full-size pictures are in a different folder, by changing:<br />
if ( $handle = opendir(&#8220;.&#8221;) ) {<br />
to<br />
if ( $handle = opendir(&#8220;myimages/&#8221;) ) {<br />
But stuck after that <img src='http://www.lateralcode.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /><br />
Any help would be great!</p>
<p>Any chance of putting a comment under each picture?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tapas</title>
		<link>http://www.lateralcode.com/create-a-simple-picture-gallery-using-php/#comment-20367</link>
		<dc:creator>Tapas</dc:creator>
		<pubDate>Tue, 22 Mar 2011 06:16:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.lateralcode.com/?p=569#comment-20367</guid>
		<description>Hello Sir
I am new to PHP. I have downloaded and tried ur code. I got the following error

Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 5060 bytes) in C:\xampp\htdocs\phpgallery\index.php on line 37


The index.php file is as follows

&lt;?php
	# SETTINGS
	$max_width = 100;
	$max_height = 100;
	
	function getPictureType($ext) {
		if ( preg_match(&#039;/jpg&#124;jpeg/i&#039;, $ext) ) {
			return &#039;jpg&#039;;
		} else if ( preg_match(&#039;/png/i&#039;, $ext) ) {
			return &#039;png&#039;;
		} else if ( preg_match(&#039;/gif/i&#039;, $ext) ) {
			return &#039;gif&#039;;
		} else {
			return &#039;&#039;;
		}
	}
	
	function getPictures() {
		global $max_width, $max_height;
		if ( $handle = opendir(&quot;.&quot;) ) {
			$lightbox = rand();
			echo &#039;&#039;;
			while ( ($file = readdir($handle)) !== false ) {
				if ( !is_dir($file) ) {
					$split = explode(&#039;.&#039;, $file); 
					$ext = $split[count($split) - 1];
					if ( ($type = getPictureType($ext)) == &#039;&#039; ) {
						continue;
					}
					if ( ! is_dir(&#039;thumbs&#039;) ) {
						mkdir(&#039;thumbs&#039;);
					}
					if ( ! file_exists(&#039;thumbs/&#039;.$file) ) {
						if ( $type == &#039;jpg&#039; ) {
							$src = imagecreatefromjpeg($file);
						} else if ( $type == &#039;png&#039; ) {
							$src = imagecreatefrompng($file);
						} else if ( $type == &#039;gif&#039; ) {
							$src = imagecreatefromgif($file);
						}
						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);
						if ( $type == &#039;jpg&#039; ) {
							imagejpeg($new, &#039;thumbs/&#039;.$file);
						} else if ( $type == &#039;png&#039; ) {
							imagepng($new, &#039;thumbs/&#039;.$file);
						} else if ( $type == &#039;gif&#039; ) {
							imagegif($new, &#039;thumbs/&#039;.$file);
						}
						imagedestroy($new);
						imagedestroy($src);
					}
					echo &#039;&lt;a href=&quot;&#039;.$file.&#039;&quot; rel=&quot;nofollow&quot;&gt;&#039;;
					echo &#039;&#039;;
					echo &#039;&lt;/a&gt;&#039;;
				}
			}
			echo &#039;&#039;;
		}
	}
?&gt;




Pictures


#pictures li {
	float:left;
	height:px;
	list-style:none outside;
	width:px;
	text-align:center;
}
img {
	border:0;
	outline:none;
}














When I commented line no. 37  i.e.  $src = imagecreatefrompng($file);
I got the pictures as thumbnails with following warnings.

Warning: imagesx(): supplied argument is not a valid Image resource in C:\xampp\htdocs\phpgallery\index.php on line 41

Warning: imagesy(): supplied argument is not a valid Image resource in C:\xampp\htdocs\phpgallery\index.php on line 41

Warning: Division by zero in C:\xampp\htdocs\phpgallery\index.php on line 46

Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\xampp\htdocs\phpgallery\index.php on line 48

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in C:\xampp\htdocs\phpgallery\index.php on line 49

Warning: imagepng(): supplied argument is not a valid Image resource in C:\xampp\htdocs\phpgallery\index.php on line 53

Warning: imagedestroy(): supplied argument is not a valid Image resource in C:\xampp\htdocs\phpgallery\index.php on line 57

Warning: imagedestroy(): supplied argument is not a valid Image resource in C:\xampp\htdocs\phpgallery\index.php on line 58


When I click on the thumbnails it shows the original pictures. 

I don&#039;t know what to do. GD Library is enabled
I have XAMPP for Windows Version 1.6.7
php version 5.2.6
Plz Help.</description>
		<content:encoded><![CDATA[<p>Hello Sir<br />
I am new to PHP. I have downloaded and tried ur code. I got the following error</p>
<p>Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 5060 bytes) in C:\xampp\htdocs\phpgallery\index.php on line 37</p>
<p>The index.php file is as follows</p>
<p>&lt;?php<br />
	# SETTINGS<br />
	$max_width = 100;<br />
	$max_height = 100;</p>
<p>	function getPictureType($ext) {<br />
		if ( preg_match(&#039;/jpg|jpeg/i&#039;, $ext) ) {<br />
			return &#039;jpg&#039;;<br />
		} else if ( preg_match(&#039;/png/i&#039;, $ext) ) {<br />
			return &#039;png&#039;;<br />
		} else if ( preg_match(&#039;/gif/i&#039;, $ext) ) {<br />
			return &#039;gif&#039;;<br />
		} else {<br />
			return &#039;&#039;;<br />
		}<br />
	}</p>
<p>	function getPictures() {<br />
		global $max_width, $max_height;<br />
		if ( $handle = opendir(&quot;.&quot;) ) {<br />
			$lightbox = rand();<br />
			echo &#039;&#8217;;<br />
			while ( ($file = readdir($handle)) !== false ) {<br />
				if ( !is_dir($file) ) {<br />
					$split = explode(&#8216;.&#8217;, $file);<br />
					$ext = $split[count($split) - 1];<br />
					if ( ($type = getPictureType($ext)) == &#8221; ) {<br />
						continue;<br />
					}<br />
					if ( ! is_dir(&#8216;thumbs&#8217;) ) {<br />
						mkdir(&#8216;thumbs&#8217;);<br />
					}<br />
					if ( ! file_exists(&#8216;thumbs/&#8217;.$file) ) {<br />
						if ( $type == &#8216;jpg&#8217; ) {<br />
							$src = imagecreatefromjpeg($file);<br />
						} else if ( $type == &#8216;png&#8217; ) {<br />
							$src = imagecreatefrompng($file);<br />
						} else if ( $type == &#8216;gif&#8217; ) {<br />
							$src = imagecreatefromgif($file);<br />
						}<br />
						if ( ($oldW = imagesx($src)) &lt; ($oldH = imagesy($src)) ) {<br />
							$newW = $oldW * ($max_width / $oldH);<br />
							$newH = $max_height;<br />
						} else {<br />
							$newW = $max_width;<br />
							$newH = $oldH * ($max_height / $oldW);<br />
						}<br />
						$new = imagecreatetruecolor($newW, $newH);<br />
						imagecopyresampled($new, $src, 0, 0, 0, 0, $newW, $newH, $oldW, $oldH);<br />
						if ( $type == &#039;jpg&#039; ) {<br />
							imagejpeg($new, &#039;thumbs/&#039;.$file);<br />
						} else if ( $type == &#039;png&#039; ) {<br />
							imagepng($new, &#039;thumbs/&#039;.$file);<br />
						} else if ( $type == &#039;gif&#039; ) {<br />
							imagegif($new, &#039;thumbs/&#039;.$file);<br />
						}<br />
						imagedestroy($new);<br />
						imagedestroy($src);<br />
					}<br />
					echo &#039;<a href="'.$file.'" rel="nofollow">&#8216;;<br />
					echo &#8221;;<br />
					echo &#8216;</a>&#8216;;<br />
				}<br />
			}<br />
			echo &#8221;;<br />
		}<br />
	}<br />
?&gt;</p>
<p>Pictures</p>
<p>#pictures li {<br />
	float:left;<br />
	height:px;<br />
	list-style:none outside;<br />
	width:px;<br />
	text-align:center;<br />
}<br />
img {<br />
	border:0;<br />
	outline:none;<br />
}</p>
<p>When I commented line no. 37  i.e.  $src = imagecreatefrompng($file);<br />
I got the pictures as thumbnails with following warnings.</p>
<p>Warning: imagesx(): supplied argument is not a valid Image resource in C:\xampp\htdocs\phpgallery\index.php on line 41</p>
<p>Warning: imagesy(): supplied argument is not a valid Image resource in C:\xampp\htdocs\phpgallery\index.php on line 41</p>
<p>Warning: Division by zero in C:\xampp\htdocs\phpgallery\index.php on line 46</p>
<p>Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\xampp\htdocs\phpgallery\index.php on line 48</p>
<p>Warning: imagecopyresampled(): supplied argument is not a valid Image resource in C:\xampp\htdocs\phpgallery\index.php on line 49</p>
<p>Warning: imagepng(): supplied argument is not a valid Image resource in C:\xampp\htdocs\phpgallery\index.php on line 53</p>
<p>Warning: imagedestroy(): supplied argument is not a valid Image resource in C:\xampp\htdocs\phpgallery\index.php on line 57</p>
<p>Warning: imagedestroy(): supplied argument is not a valid Image resource in C:\xampp\htdocs\phpgallery\index.php on line 58</p>
<p>When I click on the thumbnails it shows the original pictures. </p>
<p>I don&#8217;t know what to do. GD Library is enabled<br />
I have XAMPP for Windows Version 1.6.7<br />
php version 5.2.6<br />
Plz Help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Calestor</title>
		<link>http://www.lateralcode.com/create-a-simple-picture-gallery-using-php/#comment-10716</link>
		<dc:creator>Calestor</dc:creator>
		<pubDate>Wed, 29 Dec 2010 03:03:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.lateralcode.com/?p=569#comment-10716</guid>
		<description>Hello, This is really awesome, I have been on books and this tutorial has helped me a great deal.

 I have a request though, Could you show me and the others learning Php how to create an album, store the pictures in a datadase,(assigned to a paticular user who has to log in) and viewing them Using the same beautiful format you have used in this tutorial, please please!

Thank You so much!</description>
		<content:encoded><![CDATA[<p>Hello, This is really awesome, I have been on books and this tutorial has helped me a great deal.</p>
<p> I have a request though, Could you show me and the others learning Php how to create an album, store the pictures in a datadase,(assigned to a paticular user who has to log in) and viewing them Using the same beautiful format you have used in this tutorial, please please!</p>
<p>Thank You so much!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maky</title>
		<link>http://www.lateralcode.com/create-a-simple-picture-gallery-using-php/#comment-9712</link>
		<dc:creator>Maky</dc:creator>
		<pubDate>Mon, 20 Dec 2010 13:59:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.lateralcode.com/?p=569#comment-9712</guid>
		<description>patrick if u could please tell me where should i look in this messy javascript to fix this, I put my index.php/gallery.php in the root folder together with js and images, but my folder of pictures would be /root/gallery and Im a php coder but my js doesnt read pics</description>
		<content:encoded><![CDATA[<p>patrick if u could please tell me where should i look in this messy javascript to fix this, I put my index.php/gallery.php in the root folder together with js and images, but my folder of pictures would be /root/gallery and Im a php coder but my js doesnt read pics</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Moon</title>
		<link>http://www.lateralcode.com/create-a-simple-picture-gallery-using-php/#comment-3153</link>
		<dc:creator>Moon</dc:creator>
		<pubDate>Fri, 13 Aug 2010 04:29:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.lateralcode.com/?p=569#comment-3153</guid>
		<description>What if I want to use other type of file beside picture format? Like .doc or .pdf, is there any way to do so?</description>
		<content:encoded><![CDATA[<p>What if I want to use other type of file beside picture format? Like .doc or .pdf, is there any way to do so?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ned</title>
		<link>http://www.lateralcode.com/create-a-simple-picture-gallery-using-php/#comment-1090</link>
		<dc:creator>Ned</dc:creator>
		<pubDate>Wed, 12 May 2010 17:19:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.lateralcode.com/?p=569#comment-1090</guid>
		<description>Hey there! Great Tutorial! What about some info on each image ? We can get it from txt file or something ...</description>
		<content:encoded><![CDATA[<p>Hey there! Great Tutorial! What about some info on each image ? We can get it from txt file or something &#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ferry</title>
		<link>http://www.lateralcode.com/create-a-simple-picture-gallery-using-php/#comment-1066</link>
		<dc:creator>Ferry</dc:creator>
		<pubDate>Fri, 23 Apr 2010 02:13:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.lateralcode.com/?p=569#comment-1066</guid>
		<description>Great Toturial and it work.

But can I create a category for the image. Example if I want to create category for Room A, B, C and D. Example when I click Room A (Hyperlink) it open the thumbs for Room A.</description>
		<content:encoded><![CDATA[<p>Great Toturial and it work.</p>
<p>But can I create a category for the image. Example if I want to create category for Room A, B, C and D. Example when I click Room A (Hyperlink) it open the thumbs for Room A.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cormac</title>
		<link>http://www.lateralcode.com/create-a-simple-picture-gallery-using-php/#comment-1053</link>
		<dc:creator>Cormac</dc:creator>
		<pubDate>Wed, 07 Apr 2010 21:01:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.lateralcode.com/?p=569#comment-1053</guid>
		<description>Hi, 
Firstly I am totally new to PHP, and I am jumping in the deep end here.
I am trying to get this to work with CakePHP and I am nearly there just have the following 4 error messages:

Warning (2): imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions [APP\views\pages\gallery.ctp, line 54]

Code &#124; Context

$imagedir	=	&quot;D:\Domains\gdchauffeurs.com\wwwroot/app/webroot/img/gallery/&quot;
$thumbs	=	&quot;D:\Domains\gdchauffeurs.com\wwwroot/app/webroot/img/gallery/thumbs/&quot;
$max_width	=	null
$max_height	=	null
$handle	=	resource
$lightbox	=	8360
$file	=	&quot;mercname.jpg&quot;
$split	=	array(
	&quot;mercname&quot;,
	&quot;jpg&quot;
)
$ext	=	&quot;jpg&quot;
$type	=	&quot;jpg&quot;
$src	=	resource
$oldW	=	320
$oldH	=	240
$newW	=	null
$newH	=	0

imagecreatetruecolor - [internal], line ??
getPictures - APP\views\pages\gallery.ctp, line 54
include - APP\views\pages\gallery.ctp, line 98
View::_render() - CORE\cake\libs\view\view.php, line 666
View::render() - CORE\cake\libs\view\view.php, line 376
Controller::render() - CORE\cake\libs\controller\controller.php, line 803
PagesController::display() - APP\controllers\pages_controller.php, line 82
Object::dispatchMethod() - CORE\cake\libs\object.php, line 118
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 227
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 194
require - APP\webroot\index.php, line 88
[main] - CORE\index.php, line 61

Warning (2): imagecopyresampled(): supplied argument is not a valid Image resource [APP\views\pages\gallery.ctp, line 55]

Code &#124; Context

$imagedir	=	&quot;D:\Domains\gdchauffeurs.com\wwwroot/app/webroot/img/gallery/&quot;
$thumbs	=	&quot;D:\Domains\gdchauffeurs.com\wwwroot/app/webroot/img/gallery/thumbs/&quot;
$max_width	=	null
$max_height	=	null
$handle	=	resource
$lightbox	=	8360
$file	=	&quot;mercname.jpg&quot;
$split	=	array(
	&quot;mercname&quot;,
	&quot;jpg&quot;
)
$ext	=	&quot;jpg&quot;
$type	=	&quot;jpg&quot;
$src	=	resource
$oldW	=	320
$oldH	=	240
$newW	=	null
$newH	=	0
$new	=	false

imagecopyresampled - [internal], line ??
getPictures - APP\views\pages\gallery.ctp, line 55
include - APP\views\pages\gallery.ctp, line 98
View::_render() - CORE\cake\libs\view\view.php, line 666
View::render() - CORE\cake\libs\view\view.php, line 376
Controller::render() - CORE\cake\libs\controller\controller.php, line 803
PagesController::display() - APP\controllers\pages_controller.php, line 82
Object::dispatchMethod() - CORE\cake\libs\object.php, line 118
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 227
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 194
require - APP\webroot\index.php, line 88
[main] - CORE\index.php, line 61

Warning (2): imagejpeg(): supplied argument is not a valid Image resource [APP\views\pages\gallery.ctp, line 57]

Code &#124; Context

$imagedir	=	&quot;D:\Domains\gdchauffeurs.com\wwwroot/app/webroot/img/gallery/&quot;
$thumbs	=	&quot;D:\Domains\gdchauffeurs.com\wwwroot/app/webroot/img/gallery/thumbs/&quot;
$max_width	=	null
$max_height	=	null
$handle	=	resource
$lightbox	=	8360
$file	=	&quot;mercname.jpg&quot;
$split	=	array(
	&quot;mercname&quot;,
	&quot;jpg&quot;
)
$ext	=	&quot;jpg&quot;
$type	=	&quot;jpg&quot;
$src	=	resource
$oldW	=	320
$oldH	=	240
$newW	=	null
$newH	=	0
$new	=	false

imagejpeg - [internal], line ??
getPictures - APP\views\pages\gallery.ctp, line 57
include - APP\views\pages\gallery.ctp, line 98
View::_render() - CORE\cake\libs\view\view.php, line 666
View::render() - CORE\cake\libs\view\view.php, line 376
Controller::render() - CORE\cake\libs\controller\controller.php, line 803
PagesController::display() - APP\controllers\pages_controller.php, line 82
Object::dispatchMethod() - CORE\cake\libs\object.php, line 118
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 227
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 194
require - APP\webroot\index.php, line 88
[main] - CORE\index.php, line 61

Warning (2): imagedestroy(): supplied argument is not a valid Image resource [APP\views\pages\gallery.ctp, line 63]


Any idea&#039;s?
Thanks</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Firstly I am totally new to PHP, and I am jumping in the deep end here.<br />
I am trying to get this to work with CakePHP and I am nearly there just have the following 4 error messages:</p>
<p>Warning (2): imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions [APP\views\pages\gallery.ctp, line 54]</p>
<p>Code | Context</p>
<p>$imagedir	=	&#8220;D:\Domains\gdchauffeurs.com\wwwroot/app/webroot/img/gallery/&#8221;<br />
$thumbs	=	&#8220;D:\Domains\gdchauffeurs.com\wwwroot/app/webroot/img/gallery/thumbs/&#8221;<br />
$max_width	=	null<br />
$max_height	=	null<br />
$handle	=	resource<br />
$lightbox	=	8360<br />
$file	=	&#8220;mercname.jpg&#8221;<br />
$split	=	array(<br />
	&#8220;mercname&#8221;,<br />
	&#8220;jpg&#8221;<br />
)<br />
$ext	=	&#8220;jpg&#8221;<br />
$type	=	&#8220;jpg&#8221;<br />
$src	=	resource<br />
$oldW	=	320<br />
$oldH	=	240<br />
$newW	=	null<br />
$newH	=	0</p>
<p>imagecreatetruecolor &#8211; [internal], line ??<br />
getPictures &#8211; APP\views\pages\gallery.ctp, line 54<br />
include &#8211; APP\views\pages\gallery.ctp, line 98<br />
View::_render() &#8211; CORE\cake\libs\view\view.php, line 666<br />
View::render() &#8211; CORE\cake\libs\view\view.php, line 376<br />
Controller::render() &#8211; CORE\cake\libs\controller\controller.php, line 803<br />
PagesController::display() &#8211; APP\controllers\pages_controller.php, line 82<br />
Object::dispatchMethod() &#8211; CORE\cake\libs\object.php, line 118<br />
Dispatcher::_invoke() &#8211; CORE\cake\dispatcher.php, line 227<br />
Dispatcher::dispatch() &#8211; CORE\cake\dispatcher.php, line 194<br />
require &#8211; APP\webroot\index.php, line 88<br />
[main] &#8211; CORE\index.php, line 61</p>
<p>Warning (2): imagecopyresampled(): supplied argument is not a valid Image resource [APP\views\pages\gallery.ctp, line 55]</p>
<p>Code | Context</p>
<p>$imagedir	=	&#8220;D:\Domains\gdchauffeurs.com\wwwroot/app/webroot/img/gallery/&#8221;<br />
$thumbs	=	&#8220;D:\Domains\gdchauffeurs.com\wwwroot/app/webroot/img/gallery/thumbs/&#8221;<br />
$max_width	=	null<br />
$max_height	=	null<br />
$handle	=	resource<br />
$lightbox	=	8360<br />
$file	=	&#8220;mercname.jpg&#8221;<br />
$split	=	array(<br />
	&#8220;mercname&#8221;,<br />
	&#8220;jpg&#8221;<br />
)<br />
$ext	=	&#8220;jpg&#8221;<br />
$type	=	&#8220;jpg&#8221;<br />
$src	=	resource<br />
$oldW	=	320<br />
$oldH	=	240<br />
$newW	=	null<br />
$newH	=	0<br />
$new	=	false</p>
<p>imagecopyresampled &#8211; [internal], line ??<br />
getPictures &#8211; APP\views\pages\gallery.ctp, line 55<br />
include &#8211; APP\views\pages\gallery.ctp, line 98<br />
View::_render() &#8211; CORE\cake\libs\view\view.php, line 666<br />
View::render() &#8211; CORE\cake\libs\view\view.php, line 376<br />
Controller::render() &#8211; CORE\cake\libs\controller\controller.php, line 803<br />
PagesController::display() &#8211; APP\controllers\pages_controller.php, line 82<br />
Object::dispatchMethod() &#8211; CORE\cake\libs\object.php, line 118<br />
Dispatcher::_invoke() &#8211; CORE\cake\dispatcher.php, line 227<br />
Dispatcher::dispatch() &#8211; CORE\cake\dispatcher.php, line 194<br />
require &#8211; APP\webroot\index.php, line 88<br />
[main] &#8211; CORE\index.php, line 61</p>
<p>Warning (2): imagejpeg(): supplied argument is not a valid Image resource [APP\views\pages\gallery.ctp, line 57]</p>
<p>Code | Context</p>
<p>$imagedir	=	&#8220;D:\Domains\gdchauffeurs.com\wwwroot/app/webroot/img/gallery/&#8221;<br />
$thumbs	=	&#8220;D:\Domains\gdchauffeurs.com\wwwroot/app/webroot/img/gallery/thumbs/&#8221;<br />
$max_width	=	null<br />
$max_height	=	null<br />
$handle	=	resource<br />
$lightbox	=	8360<br />
$file	=	&#8220;mercname.jpg&#8221;<br />
$split	=	array(<br />
	&#8220;mercname&#8221;,<br />
	&#8220;jpg&#8221;<br />
)<br />
$ext	=	&#8220;jpg&#8221;<br />
$type	=	&#8220;jpg&#8221;<br />
$src	=	resource<br />
$oldW	=	320<br />
$oldH	=	240<br />
$newW	=	null<br />
$newH	=	0<br />
$new	=	false</p>
<p>imagejpeg &#8211; [internal], line ??<br />
getPictures &#8211; APP\views\pages\gallery.ctp, line 57<br />
include &#8211; APP\views\pages\gallery.ctp, line 98<br />
View::_render() &#8211; CORE\cake\libs\view\view.php, line 666<br />
View::render() &#8211; CORE\cake\libs\view\view.php, line 376<br />
Controller::render() &#8211; CORE\cake\libs\controller\controller.php, line 803<br />
PagesController::display() &#8211; APP\controllers\pages_controller.php, line 82<br />
Object::dispatchMethod() &#8211; CORE\cake\libs\object.php, line 118<br />
Dispatcher::_invoke() &#8211; CORE\cake\dispatcher.php, line 227<br />
Dispatcher::dispatch() &#8211; CORE\cake\dispatcher.php, line 194<br />
require &#8211; APP\webroot\index.php, line 88<br />
[main] &#8211; CORE\index.php, line 61</p>
<p>Warning (2): imagedestroy(): supplied argument is not a valid Image resource [APP\views\pages\gallery.ctp, line 63]</p>
<p>Any idea&#8217;s?<br />
Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kos mashang</title>
		<link>http://www.lateralcode.com/create-a-simple-picture-gallery-using-php/#comment-1028</link>
		<dc:creator>kos mashang</dc:creator>
		<pubDate>Thu, 18 Mar 2010 00:52:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.lateralcode.com/?p=569#comment-1028</guid>
		<description>looks like i am not the only one with the directory bug, 
well i have managed to get it to create the /thumbs/ folder inside images (one i that assigned!) but it will not create the thumbs in it,
if i assign the alt tag as the $file, you can see a link (text ) to the image but then again no thumbs inside the thumbs folder..... 
for any one whom wants to see the script modified by me here it is (BTW i am a total noob at PHP)

	&lt;?php
		# SETTINGS
		$max_width = 100;
		$max_height = 100;
		
		function getPictureType($ext) {
			if ( preg_match(&#039;/jpg&#124;jpeg/i&#039;, $ext) ) {
				return &#039;jpg&#039;;
			} else if ( preg_match(&#039;/png/i&#039;, $ext) ) {
				return &#039;png&#039;;
			} else if ( preg_match(&#039;/gif/i&#039;, $ext) ) {
				return &#039;gif&#039;;
			} else {
				return &#039;&#039;;
			}
		}
		
		function getPictures() {
			global $max_width, $max_height;
			if ( $handle = opendir(&quot;./images&quot;) ) {
				$lightbox = rand();
				echo &#039;&#039;;
				while ( ($file = readdir($handle)) !== false ) {
					if ( !is_dir($file) ) {
						$split = explode(&#039;./images/&#039;, $file); 
						$ext = $split[count($split) - 1];
						if ( ($type = getPictureType($ext)) == &#039;&#039; ) {
							continue;
						}
						if ( ! is_dir(&#039;./images/thumbs&#039;) ) {
							mkdir(&#039;./images/thumbs&#039;);
						}
						if ( ! file_exists(&#039;./images/&#039;.$file) ) {
							if ( $type == &#039;jpg&#039; ) {
								$src = imagecreatefromjpeg(&#039;./images/&#039;.$file);
							} else if ( $type == &#039;png&#039; ) {
								$src = imagecreatefrompng(&#039;./images/&#039;.$file);
							} else if ( $type == &#039;gif&#039; ) {
								$src = imagecreatefromgif(&#039;./images/&#039;.$file);
							}
							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);
							if ( $type == &#039;jpg&#039; ) {
								imagejpeg($new, &#039;./images/thumbs/&#039;.$file);
							} else if ( $type == &#039;png&#039; ) {
								imagepng($new, &#039;./images/thumbs/&#039;.$file);
							} else if ( $type == &#039;gif&#039; ) {
								imagegif($new, &#039;./images/thumbs/&#039;.$file);
							}
							imagedestroy($new);
							imagedestroy($src);
						}
						echo &#039;&lt;a href=&quot;/images/&#039;.$file.&#039;&quot; rel=&quot;nofollow&quot;&gt;&#039;;
						echo &#039;&#039;;
						echo &#039;&lt;/a&gt;&#039;;
					}
				}
				echo &#039;&#039;;
			}
		}
	?&gt;
	
	
	
	
	Pictures
	
	
	#pictures li {
		float:left;
		height:px;
		list-style:none outside;
		width:px;
		text-align:center;
	}
	img {
		border:0;
		outline:none;
	}
	
	
	

	


	
	
	
	
	</description>
		<content:encoded><![CDATA[<p>looks like i am not the only one with the directory bug,<br />
well i have managed to get it to create the /thumbs/ folder inside images (one i that assigned!) but it will not create the thumbs in it,<br />
if i assign the alt tag as the $file, you can see a link (text ) to the image but then again no thumbs inside the thumbs folder&#8230;..<br />
for any one whom wants to see the script modified by me here it is (BTW i am a total noob at PHP)</p>
<p>	&lt;?php<br />
		# SETTINGS<br />
		$max_width = 100;<br />
		$max_height = 100;</p>
<p>		function getPictureType($ext) {<br />
			if ( preg_match(&#039;/jpg|jpeg/i&#039;, $ext) ) {<br />
				return &#039;jpg&#039;;<br />
			} else if ( preg_match(&#039;/png/i&#039;, $ext) ) {<br />
				return &#039;png&#039;;<br />
			} else if ( preg_match(&#039;/gif/i&#039;, $ext) ) {<br />
				return &#039;gif&#039;;<br />
			} else {<br />
				return &#039;&#039;;<br />
			}<br />
		}</p>
<p>		function getPictures() {<br />
			global $max_width, $max_height;<br />
			if ( $handle = opendir(&quot;./images&quot;) ) {<br />
				$lightbox = rand();<br />
				echo &#039;&#8217;;<br />
				while ( ($file = readdir($handle)) !== false ) {<br />
					if ( !is_dir($file) ) {<br />
						$split = explode(&#8216;./images/&#8217;, $file);<br />
						$ext = $split[count($split) - 1];<br />
						if ( ($type = getPictureType($ext)) == &#8221; ) {<br />
							continue;<br />
						}<br />
						if ( ! is_dir(&#8216;./images/thumbs&#8217;) ) {<br />
							mkdir(&#8216;./images/thumbs&#8217;);<br />
						}<br />
						if ( ! file_exists(&#8216;./images/&#8217;.$file) ) {<br />
							if ( $type == &#8216;jpg&#8217; ) {<br />
								$src = imagecreatefromjpeg(&#8216;./images/&#8217;.$file);<br />
							} else if ( $type == &#8216;png&#8217; ) {<br />
								$src = imagecreatefrompng(&#8216;./images/&#8217;.$file);<br />
							} else if ( $type == &#8216;gif&#8217; ) {<br />
								$src = imagecreatefromgif(&#8216;./images/&#8217;.$file);<br />
							}<br />
							if ( ($oldW = imagesx($src)) &lt; ($oldH = imagesy($src)) ) {<br />
								$newW = $oldW * ($max_width / $oldH);<br />
								$newH = $max_height;<br />
							} else {<br />
								$newW = $max_width;<br />
								$newH = $oldH * ($max_height / $oldW);<br />
							}<br />
							$new = imagecreatetruecolor($newW, $newH);<br />
							imagecopyresampled($new, $src, 0, 0, 0, 0, $newW, $newH, $oldW, $oldH);<br />
							if ( $type == &#039;jpg&#039; ) {<br />
								imagejpeg($new, &#039;./images/thumbs/&#039;.$file);<br />
							} else if ( $type == &#039;png&#039; ) {<br />
								imagepng($new, &#039;./images/thumbs/&#039;.$file);<br />
							} else if ( $type == &#039;gif&#039; ) {<br />
								imagegif($new, &#039;./images/thumbs/&#039;.$file);<br />
							}<br />
							imagedestroy($new);<br />
							imagedestroy($src);<br />
						}<br />
						echo &#039;<a href="/images/'.$file.'" rel="nofollow">&#8216;;<br />
						echo &#8221;;<br />
						echo &#8216;</a>&#8216;;<br />
					}<br />
				}<br />
				echo &#8221;;<br />
			}<br />
		}<br />
	?&gt;</p>
<p>	Pictures</p>
<p>	#pictures li {<br />
		float:left;<br />
		height:px;<br />
		list-style:none outside;<br />
		width:px;<br />
		text-align:center;<br />
	}<br />
	img {<br />
		border:0;<br />
		outline:none;<br />
	}</p>
]]></content:encoded>
	</item>
</channel>
</rss>

