<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DOC776.org &#187; thumbnail</title>
	<atom:link href="http://www.doc776.org/tag/thumbnail/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.doc776.org</link>
	<description>This is the era of information.</description>
	<lastBuildDate>Mon, 02 Jan 2012 00:05:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Easy Image Class</title>
		<link>http://www.doc776.org/2009/06/easy-image-class/</link>
		<comments>http://www.doc776.org/2009/06/easy-image-class/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 03:22:27 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Class]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[gd]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[thumbnail]]></category>

		<guid isPermaLink="false">http://www.doc776.org/?p=127</guid>
		<description><![CDATA[I needed something simple to grab images from MySQL database and display them. Slowly it grew into a very handy class. This class can be used to manipulate images stored in files or in a MySQL database. It can read images from files and store them in a MySQL database table, and vice-versa. The class [...]]]></description>
			<content:encoded><![CDATA[<p>I needed something simple to grab images from MySQL database and display them. Slowly it grew into a very handy class.</p>
<p>This class can be used to manipulate images stored in files or in a MySQL database. It can read images from files and store them in a MySQL database table, and vice-versa. The class can also convert images between GIF, JPEG and PNG formats, as well resize the images to create thumbnails.</p>
<p>Documentation:<br />
Coming Soon&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.doc776.org/2009/06/easy-image-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image Thumbnail / Resize Function</title>
		<link>http://www.doc776.org/2009/06/image-thumbnail-resize-function/</link>
		<comments>http://www.doc776.org/2009/06/image-thumbnail-resize-function/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 19:45:02 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[gd]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[thumbnail]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.doc776.org/?p=104</guid>
		<description><![CDATA[Log time ago I wrote this function for my friend&#8217;s gallery website. The function is straight forward and uses the GD library of PHP. You may resize the image by giving it the maximum width and height you want the thumbnail to have. The function acts as an extension of the GD library so to [...]]]></description>
			<content:encoded><![CDATA[<p>Log time ago I wrote this function for my friend&#8217;s gallery website. The function is straight forward and uses the GD library of PHP. You may resize the image by giving it the maximum width and height you want the thumbnail to have. The function acts as an extension of the GD library so to speak, so you have to pass the image resource. An additional argument may be passed stating if you want the thumbnail to be square or not, by default it is false. If it is true the width:height ratio will not be change, it only fills the empty space with black color and places the thumbnail image in the center of the square.</p>
<p>imagethumb(image resource, max width, max height, fill to make square)<br />
1 &#8211; (GD image resource) Straight forward teh image resource loaded by GD library.<br />
2 &#8211; (int) maximum width of thumbnail<br />
3 &#8211; (int) maximum width of thumbnail<br />
4 &#8211; (true/false) make thumbnail square</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> imagethumb<span style="color: #009900;">&#40;</span><span style="color: #000088;">$old_im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit_w</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit_h</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">,</span> <span style="color: #000088;">$fill</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//get original dimensions</span>
	<span style="color: #000088;">$old_w</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagesx</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$old_im</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$old_h</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagesy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$old_im</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//first resize by width if overflow else set old to new</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$old_w</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$limit_w</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//get reduction percent</span>
		<span style="color: #000088;">$reduce_percent</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$limit_w</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$old_w</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//set new w and h</span>
		<span style="color: #000088;">$new_w</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$old_w</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$reduce_percent</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$new_h</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$old_h</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$reduce_percent</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//set as the old dimensions</span>
		<span style="color: #000088;">$new_w</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$old_w</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$new_h</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$old_h</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//second resize by height if still overflows</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_h</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$limit_h</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//get reduction percent</span>
		<span style="color: #000088;">$reduce_percent</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$limit_h</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$new_h</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//set new w and h</span>
		<span style="color: #000088;">$new_w</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_w</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$reduce_percent</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$new_h</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_h</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$reduce_percent</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fill</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//height offset picture, to keep centered</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_h</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$limit_h</span><span style="color: #009900;">&#41;</span>
			<span style="color: #000088;">$h_offset</span> <span style="color: #339933;">=</span> <span style="color: #990000;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$limit_h</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$new_h</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">else</span>
			<span style="color: #000088;">$h_offset</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//width offset picture, to keep centered</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_w</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$limit_w</span><span style="color: #009900;">&#41;</span>
			<span style="color: #000088;">$w_offset</span> <span style="color: #339933;">=</span> <span style="color: #990000;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$limit_w</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$new_w</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">else</span>
			<span style="color: #000088;">$w_offset</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//make new image and copy to it</span>
		<span style="color: #000088;">$new_im</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatetruecolor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$limit_w</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit_h</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
		<span style="color: #000088;">$new_im</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatetruecolor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_w</span><span style="color: #339933;">,</span> <span style="color: #000088;">$new_h</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">imagecopyresampled</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$old_im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$w_offset</span><span style="color: #339933;">,</span> <span style="color: #000088;">$h_offset</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$new_w</span><span style="color: #339933;">,</span> <span style="color: #000088;">$new_h</span><span style="color: #339933;">,</span> <span style="color: #000088;">$old_w</span><span style="color: #339933;">,</span> <span style="color: #000088;">$old_h</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$new_im</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.doc776.org/2009/06/image-thumbnail-resize-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

