Вход Регистрация
* Pelmeshka

Превью картинок

  1. function resize ($filename, $size)
  2. {
  3. $pref = 'mini_';
  4. $img = strtolower(strrchr(basename($filename), "."));
  5. $imgname = basename($filename);
  6. $formats = array('.jpg', '.gif', '.png', '.bmp');
  7. if (in_array($img, $formats))
  8. {
  9. list($width, $height) = getimagesize($filename);
  10. $new_height = $height * $size;
  11. $new_width = $new_height / $width;
  12. $thumb = imagecreatetruecolor($size, $new_width);
  13. switch ($img)
  14. {
  15. case '.jpg': $source = @imagecreatefromjpeg($filename); break;
  16. //создаем превьюшки
  17. case '.gif': $source = @imagecreatefromgif($filename); break;
  18. case '.png': $source = @imagecreatefrompng($filename); break;
  19. case '.bmp': $source = @imagecreatefromwbmp($filename); break;
  20. }
  21. imagecopyresized($thumb, $source, 0, 0, 0, 0, $size, $new_width, $width, $height);
  22. switch ($img)
  23. {
  24. case '.jpg': imagejpeg($thumb, $pref.$imgname); break;
  25. case '.gif': imagegif($thumb, $pref.$imgname); break;
  26. case '.png': imagepng($thumb, $pref.$imgname); break;
  27. case '.bmp': imagewbmp($thumb, $pref.$imgname); break;
  28. }
  29. }
  30. else return 'Error';
  31. @imagedestroy($thumb);
  32. @imagedestroy($source);
  33. return $imgname;
  34. }
» Описание: Превью картинок
» Время добавления: 22 Июля 2015 в 06:38
» Посмотров: 2123
» textarea
» Рейтинг: [+1 | -1]
Комментарии [0]
Онлайн: 3
Реклама