thumbnail.inc.php


SUBMITTED BY: Guest

DATE: Dec. 16, 2013, 7:56 a.m.

FORMAT: PHP

SIZE: 780 Bytes

HITS: 694

  1. <?php
  2. function thumbnail($img_src_str) {
  3. global $row_conf;
  4. $img_src = './' . $row_conf['CONTAIN'] . '/' . $img_src_str;
  5. $im = imagecreatefromjpeg($img_src);
  6. list($src_width, $src_height) = getimagesize($img_src);
  7. if($src_width >= $src_height)
  8. {
  9. $new_image_width = 120;
  10. $new_image_height = $src_height * 150 / $src_width;
  11. }
  12. if($src_width < $src_height)
  13. {
  14. $new_image_height = 120;
  15. $new_image_width = $src_width * 150 / $src_height;
  16. }
  17. $new_image = imagecreatetruecolor($new_image_width, $new_image_height);
  18. imagecopyresampled($new_image, $im, 0, 0, 0, 0, $new_image_width,$new_image_height, $src_width, $src_height);
  19. imagejpeg($new_image,"./thumb/$img_src_str", 100);
  20. }
  21. ?>

comments powered by Disqus