Hi Valentin,

valentin wrote:
>  a) how to verify if the uploaded file is an image ?
Someone covered that last week, I think.

>  b) how to print the image?
???

>  c) how to resize the image?
I wrote this some time ago for a car sales dept, so they could upload large 
photos without resizing them. It ruins the quality though.
This is just the resize bit, but it may help you if you adapt it.
If the photo is larger than 600x600, it resizes them.

<?php
$myphoto = $_FILES['filename']['name'];
if (substr($myphoto, -3) == "jpg") {
  $addfile = move_uploaded_file($_FILES['filename']['tmp_name'],$myphoto);
  // resize photo if necessary
  define('MAXWIDTH',600);
  define('MAXHEIGHT',600);
  $img = imagecreatefromjpeg($myphoto);
  $width = imagesx($img);
  $height = imagesy($img);
  $scale = min(MAXWIDTH/$width,MAXHEIGHT/$height);
  if ($scale < 1) {
    $new_width = floor($width * $scale);
    $new_height = floor($height * $scale);
    $new_img = imagecreatetruecolor($new_width,$new_height);
    
imagecopyresized($new_img,$img,0,0,0,0,$new_width,$new_height,$width,$height);
    imagedestroy($img);
    imagejpeg($new_img, $myphoto);
  }
  // resize end
  $goto = $_SERVER['PHP_SELF']."?addfile=yes";
  header("Location: $goto");
  exit;
}
?>

Regards, Bob.



Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to