[PHP] Image upload and scaling
Hi, I am trying to make a util whereby ppl can upload their own images to my server for me to automatically display them. The below code works fine, but I have the following problem. It only works fne if everyone complies to a standard of a set width and height for the image. This is not always possible, so I'm looking for a way to accept the image in any form they have and then to scale it to fit within an acceptable height/width range. This I need help with, so if someone could hep me ( at the hand of my current code) I would be very pleased. Thanks Petre below my code snippet ?php if ($submit) { if ($file != none) { $current_time = time(); $location_pic = /home/www/imgs/listings/.$current_time.$file_name; $url_pic = http://www.website.co.za/imgs/listings/.$current_time.$file_name; copy ($file,$location_pic); $db= mysql_pconnect(localhost,db_user,db_password); mysql_select_db(DB_NAME,$db); $sql = update table set location_pic = \$location_pic\, url_pic = \$url_pic\ where id = \$id_pic\ ; $result = mysql_query($sql); } echo Picture Uploaded! Thank You!br; echo Below is a preview of how your logo will look. If it displays incorrectly, adjust your image with an image editor of choice and upload again.br; echo img src=\$url_pic\ width=\350\ height=\150\; }else { echo Please use this form to upload image.brbrbr form method=\post\ action=\$PHP_SELF\ enctype=\multipart/form-data\ Logo Location : input type=\file\ name=\file\brbrbrbrPlease Note!Your image must be smaller than 50KB! input type=\hidden\ name=\MAX_FILE_SIZE\ value=\5\ input type=\hidden\ name=\id_pic\ value=\$id\br input type=\submit\ name=\submit\ value=\submit\ ;} ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image upload and scaling
Someone just mentioned ImageMagick... Check it out: http://www.imagemagick.org/ ImageMagickTM is a robust collection of tools and libraries to read, write, and manipulate an image in many image formats (over 68 major formats) including popular formats like TIFF, JPEG, PNG, PDF, PhotoCD, and GIF. With ImageMagick you can create images dynamically, making it suitable for Web applications. You can also resize, rotate, sharpen, color reduce, or add special effects to an image and save your completed work in the same or differing image format. Image processing operations are available from the command line, as well as through C, C++, Perl, or Java programming interfaces. Or you can check out the built in gd functions. http://www.php.net/manual/en/ref.image.php Sam On 3/11/02 12:21 PM, P.Agenbag [EMAIL PROTECTED] wrote: Hi, I am trying to make a util whereby ppl can upload their own images to my server for me to automatically display them. The below code works fine, but I have the following problem. It only works fne if everyone complies to a standard of a set width and height for the image. This is not always possible, so I'm looking for a way to accept the image in any form they have and then to scale it to fit within an acceptable height/width range. This I need help with, so if someone could hep me ( at the hand of my current code) I would be very pleased. Thanks Petre below my code snippet -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php