:
This message was edited by emperor at 2003-11-25 9:37:10
: : Hi,
: :
: : I need to create certain sized thumnails from a .jpg file that's in the same location as my .php file. The .php sould open the .jpg, create a thumnail and save it to the same place
: :
NetGert[/italic]
: :
: (Now edited to include proper formatting on the code!)
:
: To do this you need the GD graphics library - it comes bundled as standard with PHP 4.3.x, so if you have an older version of PHP either upgrade or check out
http://www.boutell.com/gd for info on installing the GD library. You may need to recompile PHP for GD support (I did) - although PHP comes bundled with GD you'll still need to ./configure --with-gd --with-jpeg-dir etc. (I assume you're on a linux/unix-style OS, I'm not sure how to use GD on a Windows install).
:
: Once you have that sorted, do this:
:
:
<?php
: $src = ImageCreateFromJPEG ($src_filename);
:
: $width = ImageSx ($src);
: $height = ImageSy ($src);
: $x = $desired_width;
: $y = $desired_height;
:
: $dst = ImageCreateTrueColor ($x, $y);
: ImageCopyResampled ($dst, $src, 0, 0, 0, 0, $x, $y, $width, $height);
: ImageJPEG ($dst, $dst_filename); // or ImagePNG or whatever
: ?>
:
: Note the function names do not need to be capitalised, I just write them that way to make them easier to read, they're all lowercase in the PHP manual.
:
: Hope this helps
:
:
:
:
:
This code gives me an error saying that
imagecreatefromjpeg is undefined. I assume this is because GD library is not installed. I have PHP 4.3.4. Doesn't GD come with that? I downloaded GD library but can't get it to be used by PHP. Any ideas?
NetGert[/italic]