scriptul asta ar trebui sa urce o imagine jpg pe server si s-o scaleze la o rezolutie mai mica........faza e ca-mi da eraore la decodare.... help..
<?php
if ($_FILES['avatar']['name']!=''){
if ($_POST[id_type]=='yahoo.com') { $fprefix='y_'; }
elseif ($_POST[id_type]=='hotmail.com') { $fprefix='hm_'; }
elseif ($_POST[id_type]=='gmail.com') { $fprefix='g_'; }
elseif ($_POST[id_type]=='aim.com') { $fprefix='aim_'; }
elseif ($_POST[id_type]=='skype') { $fprefix='sk_'; }
//ext
$ext = ".jpg";
//end ext
$fileFname = $fprefix . $_POST['id'] . $ext;
copy ($_FILES['avatar']['tmp_name'], "avatare/"$fileFname) or die ("Nu s-a putut copia avatarul pe server!");
$data = fread(fopen($_FILES['avatar']['tmp_name'], "rb"), filesize($_FILES['avatar']['tmp_name']));
$src_image = imagecreatefromstring($data);
$width = imagesx($src_image);
$height = imagesy($src_image);
if ($height > 128 OR $width > 128){
if ($width < $height) {
$av_ratio1 = $width / $height;
$av_height = 128;
$av_width = round(128 * $av_ratio1);}
else {$av_ratio2 = $height / $width;
$av_width = 128;
$av_height = round(128 * $av_ratio2);}}
elseif ($height == 128 AND $width == 128)
{$av_height = 128;
$av_width = 128;}
else {$av_height=$height;
$av_width=$width;}
//resizing
$tmpimg = tempnam("/avatare", "MKUP");
system("djpeg $fileFname >$tmpimg") or die ("Error deconverting...");
system("pnmscale -xy $width $height $tmpimg") or die ("Error scalling");
system("cjpeg -smoo 10 -qual 50 >$fileFname.final") or die("Error converting");
unlink($tmpimg);
} else {$fileFname = 'noavatar.jpg'; $av_width = 128; $av_height = 128; }
?>
JPG Upload and Resize [rezolvat]
Moderatori: Moderatori, Start Moderator
-
ashantyk
- PHPRomania Supporter
- Mesaje: 22
- Membru din: Sâm Ian 19, 2008 10:49 pm
- Localitate: Vaslui
- Contact:
JPG Upload and Resize [rezolvat]
Ultima oară modificat Dum Feb 03, 2008 12:59 am de către ashantyk, modificat 1 dată în total.
Cine este conectat
Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 25 vizitatori
