Archive

Posts Tagged ‘thumbnail’

How to create thumbnails ( Logic ) in PHP

March 15th, 2008 R Arun Raj No comments

How to create thumbnails ( Logic )

Scan a folder for JPG and PNG files (gd does not support GIF anymore, because the packing algorithm in GIF is copyrighted ).
Take each of these images, and load it.
Resize the image.
Save the image as a thumbnail.
The resizing idea is the following:

We assume the thumbnail should be 100 pixels, either wide or high.
We load the original image, and check its dimensions.
If the picture is higher than wide, we set the height of the thumb to 100 pixels.
The width of the thumbnail is the original width multiplied with 100 pixels divided by its height.
Thumbnail height = original width * (100 / original height)
This way we preserve the original aspect ratio.
If the original picture is wider than high, we do the same to the height of the thumbnail.
If they are the same, we simply create a 100×100 pixels image.
Back to table of contents
The PHP functions to use
PHP has a whole lot of functions to help us with generating graphics with gd.

For The example with php try this link
http://icant.co.uk/articles/phpthumbnails/
best of luck

Categories: Misk Tags: , , ,

Videos, Slideshows and Podcasts by Cincopa Wordpress Plugin