<?php
function resizeimg($filename, $smallimage, $w, $h) { $filelogo="logo_small.png"; $filelogo = "../img/".$filelogo; $filename = "../picture/data/photo/".$filename; $smallimage = "../picture/data/smal/".$smallimage; $ratio = $w/$h; $size_img = getimagesize($filename); if (($size_img[0]<$w) && ($size_img[1]<$h)) return true; $src_ratio=$size_img[0]/$size_img[1];
if ($ratio<$src_ratio) { $h = $w/$src_ratio; } else { $w = $h*$src_ratio; }
$dest_img = imagecreatetruecolor($w, $h); $white = imagecolorallocate($dest_img, 255, 255, 255); if ($size_img[2]==2) $src_img = imagecreatefromjpeg($filename); else if ($size_img[2]==1) $src_img = imagecreatefromgif($filename); else if ($size_img[2]==3) $src_img = imagecreatefrompng($filename);
imagealphablending($src_img, true); imagecopyresampled($dest_img, $src_img, 0, 0, 0, 0, $w, $h, $size_img[0], $size_img[1]);
$logoimage = imagecreatefrompng($filelogo);
$logow = imagesx($logoimage);
$logoh = imagesy($logoimage);
$w4=$w-$logow; $h4=$h-$logoh; imagecopy($dest_img, $logoimage, $w4, $h4, 0, 0, $logow, $logoh);
if ($size_img[2]==2) imagejpeg($dest_img, $smallimage); else if ($size_img[2]==1) imagegif($dest_img, $smallimage); else if ($size_img[2]==3) imagepng($dest_img, $smallimage);
imagedestroy($dest_img); imagedestroy($src_img); return true; }
function resizeimg2($filename, $smallimage2, $w, $h) { $filelogo="logo_small.png"; $filelogo = "../img/".$filelogo; $filename = "../picture/data/photo/".$filename; $smallimage2 = "../picture/data/big/".$smallimage2; $ratio = $w/$h; $size_img = getimagesize($filename); if (($size_img[0]<$w) && ($size_img[1]<$h)) return true; $src_ratio=$size_img[0]/$size_img[1];
if ($ratio<$src_ratio) { $h = $w/$src_ratio; } else { $w = $h*$src_ratio; }
$dest_img = imagecreatetruecolor($w, $h); $white = imagecolorallocate($dest_img, 255, 255, 255); if ($size_img[2]==2) $src_img = imagecreatefromjpeg($filename); else if ($size_img[2]==1) $src_img = imagecreatefromgif($filename); else if ($size_img[2]==3) $src_img = imagecreatefrompng($filename);
imagealphablending($src_img, true); imagecopyresampled($dest_img, $src_img, 0, 0, 0, 0, $w, $h, $size_img[0], $size_img[1]);
$logoimage = imagecreatefrompng($filelogo);
$logow = imagesx($logoimage);
$logoh = imagesy($logoimage);
$w4=$w-$logow; $h4=$h-$logoh; imagecopy($dest_img, $logoimage, $w4, $h4, 0, 0, $logow, $logoh);
if ($size_img[2]==2) imagejpeg($dest_img, $smallimage2); else if ($size_img[2]==1) imagegif($dest_img, $smallimage2); else if ($size_img[2]==3) imagepng($dest_img, $smallimage2);
imagedestroy($dest_img); imagedestroy($src_img); return true; } |