/ Published in: PHP
Expand |
Embed | Plain Text
if($_GET['size']=="tiny") { $dwidth = 85; $dheight = 57; } else { $dwidth = 600; $dheight = 460; } } else { $dwidth = 500; $dheight = 250; } if ($info['mime'] == 'image/jpeg') { $source = imagecreatefromjpeg($picurl); } else if ($info['mime'] == 'image/bmp') { $source = imagecreatefrombmp($picurl); } $source_aspect_ratio = $width / $height; $desired_aspect_ratio = $dwidth / $dheight; if ( $source_aspect_ratio > $desired_aspect_ratio ) { $temp_height = $dheight; $temp_width = ( int ) ( $dheight * $source_aspect_ratio ); } else { $temp_width = $dwidth; $temp_height = ( int ) ( $dwidth / $source_aspect_ratio ); } $temp_gdim = imagecreatetruecolor( $temp_width, $temp_height ); imagecopyresampled($temp_gdim, $source, 0, 0, 0, 0, $temp_width, $temp_height, $width, $height); $x0 = ( $temp_width - $dwidth ) / 2; $y0 = ( $temp_height - $dheight ) / 2; $thumb = imagecreatetruecolor( $dwidth, $dheight ); imagecopy($thumb,$temp_gdim,0, 0, $x0, $y0, $dwidth, $dheight ); imagejpeg($thumb, "", 100); }
You need to login to post a comment.
