PHP and MySQL Recipes by Frank M. Kromann

PHP and MySQL Recipes by Frank M. Kromann

Author:Frank M. Kromann
Language: eng
Format: epub
Publisher: Apress, Berkeley, CA


$size = [160, 120];

$orig = GetImageSize('IMG_0099.JPG');

$a1 = $size[0] / $size[1];

$a2 = $orig[0] / $orig[1];

if ($a1 > $a2) {

$d = ceil($orig[0] / $size[0]);

}

else {

$d = ceil($orig[1] / $size[1]);

}

$w = $orig[0] / $d;

$h = $orig[1] / $d;

$img = ImageCreateFromJpeg('IMG_0099.JPG');

$thumb = ImageScale($img, $w, $h);

header('Content-Type: ' . $orig['mime']);

switch ($orig[2]) {

case IMG_JPG :

case IMG_JPEG :

ImageJPEG($thumb);

break;

case IMG_PNG :

ImagePNG($thumb);

break;

case IMG_GIF :

ImageGIF($thumb);

break;

}

ImageDestroy($thumb);

ImageDestroy($img);



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.