
<a href=obrazki/obraz1_duzy.jpg><img src=miniatury/obraz1_maly.jpg></a>
<?php print '<br><input name="userfile" class=button type="file" /> <input type=text class=button name=szerokosc>Szerokosc<br>'; if ($cmd=='upload') { if ($szerokosc) { $zrodlo=$location; $imgSrc=imagecreatefromjpeg("$zrodlo"); $srcWidth=imagesx($imgSrc); $srcHeight=imagesy($imgSrc); $outWidth=$szerokosc; $proporcja=$srcWidth/$szerokosc; $outHeight=$srcHeight/$proporcja; $imgOut=imagecreatetruecolor($outWidth,$outHeight); imagerectangle($imgOut,0,0,$outWidth,$outHeight, imagecolorallocate($imgOut,0,0,0)); $dx=0; $dy=0; $dw=$outWidth; $dh=$outHeight; if ($outWidth*$srcHeight!=$outHeight*$srcWidth) { if ($srcWidth>$srcHeight) { $dw=$outWidth; $dh=($dw*$srcHeight)/$srcWidth; $dy=($outHeight-$dh)/2; } else { $dh=$outHeight; $dw=($dh*$srcWidth)/$srcHeight; $dx=($outWidth-$dw)/2; } } imagecopyresampled($imgOut,$imgSrc,$dx,$dy,0,0, $dw,$dh,$srcWidth,$srcHeight); imagepng($imgOut,"../grafika/miniatury/$nazwa"); imagedestroy($imgSrc); imagedestroy($imgOut); } } ?>