<?xml version="1.0" encoding="UTF-8"?><!-- generator="bbPress" -->

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
<title>PHP Thumb Topic: Displaying Thumbs</title>
<link>http://phpthumb.gxdlabs.com/forums/</link>
<description>Help, Suggestions, and General Discussion</description>
<language>en</language>
<pubDate>Tue, 07 Feb 2012 11:41:08 +0000</pubDate>

<item>
<title>idragon on "Displaying Thumbs"</title>
<link>http://phpthumb.gxdlabs.com/forums/topic/displaying-thumbs#post-104</link>
<pubDate>Wed, 16 Sep 2009 08:30:14 +0000</pubDate>
<dc:creator>idragon</dc:creator>
<guid isPermaLink="false">104@http://phpthumb.gxdlabs.com/forums/</guid>
<description>&#60;p&#62;thank you very much, i will try this
&#60;/p&#62;</description>
</item>
<item>
<title>d1uluv2h8 on "Displaying Thumbs"</title>
<link>http://phpthumb.gxdlabs.com/forums/topic/displaying-thumbs#post-102</link>
<pubDate>Wed, 16 Sep 2009 01:26:13 +0000</pubDate>
<dc:creator>d1uluv2h8</dc:creator>
<guid isPermaLink="false">102@http://phpthumb.gxdlabs.com/forums/</guid>
<description>&#60;p&#62;Actually, what you did uses even more resources than just displaying the image :)&#60;/p&#62;
&#60;p&#62;Here's what i did for a rudimentary caching system:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;&#60;br /&#62;
require 'ThumbLib.inc.php';&#60;br /&#62;
$options = array('jpegQuality' =&#38;gt; 90);&#60;/p&#62;
&#60;p&#62;$fileName = (isset($_GET['file'])) ? urldecode($_GET['file']) : null;&#60;/p&#62;
&#60;p&#62;$cache_dir = 'img_cache';&#60;br /&#62;
$cache_file_name = md5($fileName).'_60x60_adaptive.jpg';&#60;/p&#62;
&#60;p&#62;if (file_exists($cache_dir.'/'.$cache_file_name)) {&#60;br /&#62;
	$im = @imagecreatefromjpeg($cache_dir.'/'.$cache_file_name);&#60;/p&#62;
&#60;p&#62;	header('Content-type: image/jpeg');&#60;br /&#62;
	header('Content-Length: '. filesize($cache_dir.'/'.$cache_file_name));&#60;br /&#62;
	imagejpeg($im);&#60;br /&#62;
	imagedestroy($im);&#60;br /&#62;
	exit();&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;if (!is_dir($cache_dir)) {&#60;br /&#62;
	mkdir($cache_dir);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;if ($fileName === null &#124;&#124; !file_exists($fileName))&#60;br /&#62;
{&#60;br /&#62;
     // handle missing images however you want... perhaps show a default image??  Up to you...&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;try&#60;br /&#62;
{&#60;br /&#62;
     $thumb = PhpThumbFactory::create($fileName);&#60;br /&#62;
}&#60;br /&#62;
catch (Exception $e)&#60;br /&#62;
{&#60;br /&#62;
	// Exception&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;if (isset($thumb))&#60;br /&#62;
{&#60;br /&#62;
	$thumb-&#38;gt;adaptiveResize(60, 60);&#60;/p&#62;
&#60;p&#62;	$thumb-&#38;gt;save($cache_dir.'/'.$cache_file_name, 'jpg');&#60;/p&#62;
&#60;p&#62;	$thumb-&#38;gt;show();&#60;br /&#62;
}&#60;br /&#62;
else&#60;br /&#62;
{&#60;br /&#62;
	header(&#34;HTTP/1.0 404 Not Found&#34;);&#60;br /&#62;
	include(site_root.&#34;/404.php&#34;);&#60;br /&#62;
	exit();&#60;br /&#62;
}&#60;br /&#62;
&#60;/code&#62;
&#60;/p&#62;</description>
</item>
<item>
<title>idragon on "Displaying Thumbs"</title>
<link>http://phpthumb.gxdlabs.com/forums/topic/displaying-thumbs#post-101</link>
<pubDate>Tue, 15 Sep 2009 11:11:47 +0000</pubDate>
<dc:creator>idragon</dc:creator>
<guid isPermaLink="false">101@http://phpthumb.gxdlabs.com/forums/</guid>
<description>&#60;p&#62;Hi Guys,&#60;/p&#62;
&#60;p&#62;I need some help, and somewhat newbie in php but i get along usually.&#60;/p&#62;
&#60;p&#62;I have a special field for image classes, so i want to resize them with &#60;a href=&#34;http://www.site.com/show_imagex.php?file=%field%&#34; rel=&#34;nofollow&#34;&#62;http://www.site.com/show_imagex.php?file=%field%&#60;/a&#62; this works in my code but i have lots of images, around 20+ per page, so i think it takes a hit on the server. So i was thinking to save them and display them, something like this:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;&#38;lt;?php&#60;/p&#62;
&#60;p&#62;require_once 'ThumbLib.inc.php';&#60;/p&#62;
&#60;p&#62;$fileName = (isset($_GET['file'])) ? urldecode($_GET['file']) : null;&#60;/p&#62;
&#60;p&#62;if ($fileName === null &#124;&#124; !file_exists($fileName))&#60;br /&#62;
{&#60;br /&#62;
	echo &#34;&#38;lt;p&#38;gt;imagine lipsa&#38;lt;/p&#38;gt;&#34;;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;try&#60;br /&#62;
{&#60;br /&#62;
     $thumb = PhpThumbFactory::create($fileName);&#60;br /&#62;
}&#60;br /&#62;
catch (Exception $e)&#60;br /&#62;
{&#60;br /&#62;
     echo &#34;&#38;lt;p&#38;gt;exception&#38;lt;/p&#38;gt;&#34;;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;if(!file_exists('static/'.$fileName))&#60;br /&#62;
{&#60;/p&#62;
&#60;p&#62;$thumb-&#38;gt;adaptiveResize(170, 80);&#60;/p&#62;
&#60;p&#62;$thumb-&#38;gt;save('static/'.$fileName);&#60;br /&#62;
}&#60;br /&#62;
$new = PhpThumbFactory::create('static/'.$fileName);&#60;/p&#62;
&#60;p&#62;if(file_exists('static/'.$fileName))&#60;br /&#62;
{&#60;/p&#62;
&#60;p&#62;$new-&#38;gt;show();&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;?&#38;gt;&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;So basically get the field name, save in static, and show it. Now i dont know if this uses resources each time i call it, to create a new thumb, or it takes it from static.&#60;/p&#62;
&#60;p&#62;Any suggestions?
&#60;/p&#62;</description>
</item>

</channel>
</rss>

