You are here: Re: Script to Resizing & Upload photos « All PHP « IT news, forums, messages
Re: Script to Resizing & Upload photos

Posted by Geoff Berrow on 04/05/06 20:32

Message-ID: <1144254343.160828.190140@i40g2000cwc.googlegroups.com> from
attenborough@gmail.com contained the following:

>Hi, am hoping that someone may be able to me. Im designing a small
>website using PHP and MySQL. I would like to allow my visitors to
>upload a photo via a form on it. Im worried that people will be trying
>to upload 1mb+ images, so i am looking for a php script that will
>resize that image down to a managable 50kb file (or there abouts) and
>also give me a small thumbnail to use. Presumably then the script would
>also delete the original 1mb+ photo from the server. Ive been searching
>through google for an answer, but with not a great deal of luck. Thanks
>in advance.

Assuming the directory is writeable, your uploaded file is the variable
$file and $height is the new height of your resampled image

$src_img = imagecreatefromjpeg($file);
$new_h = $height;
$new_w = ($new_h*imagesx($src_img))/imagesy($src_img);
$dst_img = imagecreatetruecolor($new_w,$new_h);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h,
imagesx($src_img), imagesy($src_img));
imagejpeg($dst_img, "reduced_".$file, 100);

--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация