Witam, mam skrypcik do robienia miniaturek tylko z formularza ida 3 zdjecia i teraz mam pytanie musze powielic ten kod 3 razy i zmienic nazwe zmiennych czy moze jest jakis inny sposob?
Skrypt:
<?php
$pic = $_FILES['userfile']['tmp_name'];
$jpegImg = imageCreateFromJPEG($pic);
$imgsizex = imageSX($jpegImg);
$imgsizey = imageSY($jpegImg);
$jpegImg_small = imagecreatetruecolor(160, 160);
if ($imgsizex <> $imgsizey) {
if ($imgsizex > 160 OR $imgsizey > 160) {
if ($imgsizex < $imgsizey) {
$ax = $imgsizex / 160;
$axs = (integer) $ax;
$axr = 160 * $axs + ($imgsizex - 160 * $axs);
$ayr = 160 * $axs + ($imgsizex - 160 * $axs);
} else {
$ay = $imgsizey / 160;
$ays = (integer) $ay;
$ayr = 160 * $ays + ($imgsizey - 160 * $ays);
$axr = 160 * $ays + ($imgsizey - 160 * $ays);
}
$jpegImg_dst = imagecreatetruecolor($axr, $ayr);
imagecopymerge($jpegImg_dst, $jpegImg, 0, 0, 0, 0, $axr, $ayr, 100);
$imgsizex = $axr;
$imgsizey = $ayr;
} else {
$jpegImg_dst = $jpegImg;
}
} else {
$jpegImg_dst = $jpegImg;
}
imagecopyresampled($jpegImg_small, $jpegImg_dst, 0, 0, 0, 0,
160, 160, $imgsizex, $imgsizey);
0, 8);
$dirtosaveresized = getcwd()."/grafika/".$resizedfilename.".jpg";
ImageJPEG($jpegImg_small, $dirtosaveresized, 65);
?>