Jump to content

[SOLVED] Probably in wrong thread but...


chriskiely

Recommended Posts

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!

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/51184-solved-probably-in-wrong-thread-but/
Share on other sites

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; 
  }
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.