Thumbnail generation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aniltc
Forum Newbie
Posts: 17
Joined: Thu Nov 16, 2006 6:42 am

Post by aniltc »

hi all


I am storing images in a folder in the server and getting ther paths in the db.if i am doing like this how can i make thumpnails and display images please help me. i am new to GD :(
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

This thread has been split from viewtopic.php?t=35204
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

My first suggestion would be to search these forums for thumbnail as this topic is brought up once every 10 days or so.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

I wrote a tutorial that covers it: viewtopic.php?t=41743
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

Another alternative would be to use a templating system like Template Lite. It has a built-in thumbnail plugin that can auto create thumbnails for you and store them in a seperate directory.

{resize_image}

Code: Select all

{resize_image img_src="/thumbnails/" directory="/html/mysite/ad_images/" thumbdir="/html/mysite/thumbnails/" filename="Myfile.jpg" xscale="150" yscale="200" thumbname="thumb_"}
The above example would take the image Myfile.jpg located in the /html/mysite/ad_images/ directory and create a thumb_Myfile.jpg thumbnail image in the /html/mysite/thumbnails/ directory with a max image size of 150x200 and with the correct aspect ratio.

It returns...

Code: Select all

<img src="/thumbnails/thumb_Myfile.jpg" width="150" height="200" alt="image" border="0">
...in html output for the page.
aniltc
Forum Newbie
Posts: 17
Joined: Thu Nov 16, 2006 6:42 am

Post by aniltc »

thanks to all

But how can i integrate with smarty?can u show me some examples?What is Template lite?

How can i use this with Smarty?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

TemplateLite is a Smarty rewrite/improvement. It uses the same syntax as Smarty, but is considerably lighter is memory usage and overall size. It is a great tool, and one I'd recommend.
AKA Panama Jack wrote:Template Lite ... has a built-in thumbnail plugin that can auto create thumbnails for you and store them in a seperate directory.

{resize_image}
And why wasn't this more widely known, mister? 8O This is a neat feature, one I did not know about...
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

aniltc wrote:thanks to all

But how can i integrate with smarty?can u show me some examples?What is Template lite?

How can i use this with Smarty?
Template Lite is a clone of Smarty that was written from scratch to be smaller and faster.

And you really need to check the sites about how to use templating in your code. It's not an easy thing to really explain here.
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

Everah wrote:TemplateLite is a Smarty rewrite/improvement. It uses the same syntax as Smarty, but is considerably lighter is memory usage and overall size. It is a great tool, and one I'd recommend.
AKA Panama Jack wrote:Template Lite ... has a built-in thumbnail plugin that can auto create thumbnails for you and store them in a seperate directory.

{resize_image}
And why wasn't this more widely known, mister? 8O This is a neat feature, one I did not know about...
Well, it was mentioned in the news on the Template Lite site, change logs and documentation. :)

BTW, it is far more powerful than you might think. It can even download images from other sites, store them and convert them to thumbnails. It will use CURL to grab the image if CURL is installed on the server. If not then nothing will happen.

I basically got tired of doing everything in PHP and then sending two different images to the template. Now I can send just one image name and let the template do the rest. Overall it just made things so much easier.

BTW, PHP news sites only tend to look at something once and then ignore it. Unless you happen to be special to someone on the editorial staff. :)
Post Reply