Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.