function make_square_jpg($url,$newurl,$maxsize,$qual) {
list($width, $height) = getimagesize($url);
if ($width>$height) {
$centerx=$width/2-$height/2;
$centery=0;
$size=$height;
} else {
$centerx=0;
$centery=$height/2-$width/2;
$size=$width;
}
$img = imagecreatefromjpeg($url);
$thumb = imagecreatetruecolor($maxsize,$maxsize);
imagecopyresampled($thumb, $img, 0, 0, $centerx, $centery, $maxsize, $maxsize, $size, $size);
imagejpeg($thumb, $newurl,$qual);
imagedestroy($img);
imagedestroy($thumb);
}
function make_jpg($url,$newurl,$maxwidth,$maxheight,$qual) {
list($width, $height) = getimagesize($url);
$ratiow=$width/$maxwidth;
$ratioh=$height/$maxheight;
if ($ratiow > $ratioh) {
$ratio=$ratiow;
} else {
$ratio=$ratioh;
}
$thumb_width=$width/$ratio;
$thumb_height=$height/$ratio;
if ($thumb_height>$height || $thumb_width>$width) {
$thumb_height=$height;
$thumb_width=$width;
}
$img = imagecreatefromjpeg($url);
$thumb = imagecreatetruecolor($thumb_width,$thumb_height);
imagecopyresampled($thumb, $img, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height);
imagejpeg($thumb, $newurl,$qual);
imagedestroy($img);
imagedestroy($thumb);
}