Pagina 1 din 1

JPG Upload and Resize [rezolvat]

Scris: Mar Ian 29, 2008 11:55 pm
de ashantyk
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; }

?>

Scris: Mie Ian 30, 2008 12:14 am
de NooK
Foloseste un search s-a mai discutat de enshpe mii de ori

RE

Scris: Mie Ian 30, 2008 10:28 am
de ashantyk

Scris: Mie Ian 30, 2008 11:03 am
de NooK

Scris: Mie Ian 30, 2008 12:08 pm
de Quber
@NooK, el asteapta ca noi sa ne uitam in cod si sal facem el numai sa faca copy paste..!

Scris: Mie Ian 30, 2008 2:56 pm
de ashantyk
am zis si eroarea (eraore la decodare....."Error deconverting...")......... :-w mda...ms pt nik...... tot cartea te ajuta mai mult ... ca voi.........

Scris: Mie Ian 30, 2008 3:48 pm
de mihaitha

Data viitoare intreaba in alta parte. Eu unul voi refuza sa iti raspund, chiar daca voi sti raspunsul.