Resizing gif / jpg images


I’ve got a directory with 40 pictures in it. Currently named Garfield01.gif to Garfield40.gif. I want to make a random picture generator which resizes the pictures down a bit as well.
I made the following code to let the pictures appear randomly.


<?php header ("Content-type: image/gif"); $random = rand(1, 40); if ($random < 10) { $image = "Garfield0$random.gif"; } else { $image = "Garfield$random.gif"; } $fn=fopen("$image","r"); fpassthru($fn); ?>


This works fine so far. What I can’t figure out is how to resize them down. I know gif files aren’t supported anymore in th GD library and I can convert them to jpg so that’s not really a propblem. The problem is resizing them when they are displayed. They shouldn’t be saved in their smaller form, just displayed smaller.

I’ve checked the function list on but I can’t really find anything I understand or anything that I can implement. :lol:

Any ideas would be greatly appreciated.

Can`t you just specify width and height attributes in the img display tags?


Sponsor our Newsletter | Privacy Policy | Terms of Service