Guest User

Untitled

a guest
Feb 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. <?php
  2. function createThumb($source,$dest) {
  3.  
  4. $thumb_size = 150;
  5.  
  6. $size = getimagesize($source);
  7. $width = $size[0];
  8. $height = $size[1];
  9.  
  10. if($width> $height) {
  11. $x = ceil(($width - $height) / 2 );
  12. $width = $height;
  13. } elseif($height> $width) {
  14. $y = ceil(($height - $width) / 2);
  15. $height = $width;
  16. }
  17.  
  18. $new_im = ImageCreatetruecolor($thumb_size,$thumb_size);
  19. $im = imagecreatefromjpeg($source);
  20. imagecopyresampled($new_im,$im,0,0,$x,$y,$thumb_size,$thumb_size,$width,$height);
  21. imagejpeg($new_im,$dest,100);
  22.  
  23. }
  24. ?>
Add Comment
Please, Sign In to add comment