|
Posted by f.amann on 10/18/55 11:39
Hi Darren,
why do you need two forms??
you just need one form with one <INPUT TYPE='file' NAME='upfile'...
(the user selects his image with this input field)
then post the form....
after it you get your file with $_FILES[ upfile ]...
http://at.php.net/features.file-upload
then process $_FILES[ upfile ][ tmp_name ]:
for your main graphic create a new image with: $bigImage =
imagecreate($newWidth, $newHeight);
in your case $newWidth must be 500; $newHeight = 300
$origImage = imagecreatefrom*( $_FILES[ upfile ][ tmp_name] );
Notice: * depends on filetype: e.g. jpg, gif, png --> have a look on
php.net: imagecreatefromjpeg
to get the original height and width you need the getimagesize command:
$infos = getimagesize($_FILES[ upfile ][ tmp_name ]);
$origWidth = $infos[0];
$origHeight = $infos[1];
imagecopyresampled($bigImage, $origImage, 0, 0, 0, 0, $newWidth,
$newHeight, $origWidth, $origHeight);
image*($bigImage,"/image/filename.*");
Notice: * depends on filetype: e.g. jpg, gif, png --> have a look on
php.net: e.g. imagegif
just do the same for your thumbs (you just want a smaller
$newWith/$newHeight):
imagecopyresampled($thumbImage, $origImage, 0, 0, 0, 0, $newWidth,
$newHeight, $origWidth, $origHeight);
image*($thumbImage,"/tmb/filename.*");
regards
flo
[Back to original message]
|