[SOLVED] Generate Thumbnails on the fly with JPG/GIF files..
Moderator: General Moderators
Has anyone mentioned the possibility of using ImageMagick? It's a piece of software that needs to be installed on the server, but it comes on servers as standard sometimes now. It handles thumbnails really well but there's also so much you can do with images besides that, like converting the format, rotating it, adding special effects, create animated gifs from a group of images etc etc. Worth looking into I think
$pic????
Correct me if I'm wrong but your first if statement is flawed.I have tried this snippet on my server and I get a blue image with error on it, could you tell me what I am doing wrong?
Thank you,
Stephanie
Code: Select all
if(stristr($pic,".jpg"))$pic is never defined anywhere so all you will get with this script is the error message. If you change $pic to $image_to_convert you will actually get a correct result.
Can you use this script to produce multiple thumbnails of different images on the same page?
-
leenoble_uk
- Forum Contributor
- Posts: 108
- Joined: Fri May 03, 2002 10:33 am
- Location: Cheshire
- Contact:
Just to come back to the ratios. I've done this in the past and been annoyed by thin lines at the bottom of images. The problem exists because when you determine the new height using a ration of old width to new width there's every likelihood the number will be a decimal.
An image 50px x 75.86px will then be filled up with the smaller thumnail image only the last line will not be filled properly and you'll end up with whatever the canvas colour is appearing a thin line underneath the picture.
Solution is to round down.
An image 50px x 75.86px will then be filled up with the smaller thumnail image only the last line will not be filled properly and you'll end up with whatever the canvas colour is appearing a thin line underneath the picture.
Solution is to round down.
Code: Select all
<?php
$newWidth= 50;
$ratio = $newWidth/$oldWidth;
$newHeight = floor($oldHeight * $ratio);
?>