chriskiely Posted May 13, 2007 Share Posted May 13, 2007 Hi, sorry if this is in the wrong section (if so please move it if neccessary)... I am trying to create a PHP script to upload and resize images. I have read that I need need to use the djpeg, cjpeg and pnmscale UNIX utility programs from the libjpeg and libgr-progs library packages, but I have absolutely no idea how to install these packages on my server. Server details: Operating system Linux Kernel version 2.4.32-ow1 Machine Type i686 Apache version 1.3.37 (Unix) PERL version 5.8.4 PHP version 4.4.6 MySQL version 4.1.22-standard cPanel Build 11.2.6-CURRENT 11817 Theme cPanel X v2.6.0 Please could someone let me know what I need to do in order to find and install these packages. Thanks very much! Quote Link to comment https://forums.phpfreaks.com/topic/51184-solved-probably-in-wrong-thread-but/ Share on other sites More sharing options...
marmite Posted May 13, 2007 Share Posted May 13, 2007 Hi, Not sure you need all those packages! The below resizes images to 170 wide or high (depending portrait or landscape). You will also need the move_uploaded_file function (check out www.php.net for this). <? function resize_image($image_name) { $image_path = "/home/xyz/public_html/shots/" . $image_name; list($src_width, $src_height, $type, $attr) = getimagesize($image_path); if ($src_width > $src_height) { $new_w = 170; $proportion = round( ( $src_width / $new_w ), 2 ); $new_h = (int) ( $src_height / $proportion ); } else { $new_h = 170; $proportion = round( ( $src_height / $new_h ), 2 ); $new_w = (int) ( $src_width / $proportion ); } $save_path = "/home/xyz/public_html/shots/thumbnail" . $image_name; $src_img = imagecreatefromjpeg($image_path); $dst_img = imagecreatetruecolor($new_w,$new_h); imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img)); imagejpeg($dst_img, $save_path); unlink($image_path); return 1; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/51184-solved-probably-in-wrong-thread-but/#findComment-252235 Share on other sites More sharing options...
chriskiely Posted May 14, 2007 Author Share Posted May 14, 2007 Yeah I realised that this was a bit of a long winded way of go about things, also thanks for the code it's helped quite a bit. Quote Link to comment https://forums.phpfreaks.com/topic/51184-solved-probably-in-wrong-thread-but/#findComment-252612 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.