Thumbnail for uploaded images

蓝咒 提交于 2019-12-25 04:36:40

问题


i am using php tp upload images.... i was wondering

  • how to create thumbnails of images ?
  • how to customize their dimensions & proportions ?

回答1:


I've been using a class I found when I needed to do the same thing and so far, with few modifications it works great. Here you go: SimpleImage Class

<?php
  include('SimpleImage.php');
  $image = new SimpleImage();
  $image->load('picture.jpg');
  $image->resize(250,400);
  $image->save('picture2.jpg');

  // and a lot more examples at the class website.
?>

If this does not suit your needs, php manual has lots of functions to help you achieving what you need. Image




回答2:


Check out:

  • Resize/Thumbnail Images With PHP



回答3:


I created a plugin that generates thumbnails with quality and size settings and clipping method, that caches the thumbnails, enabling you to use the same image in different places and sizes in your views.

I believe this may solve your problem:

https://github.com/emersonsoares/ThumbnailsPlugin

usage:

   echo $this->Thumbnail->render('test.jpg', array(
       'width' => '100',
       'height' => '100',
       'resizeOption' => 'portrait',
       'quality' => '100'
        ), array('id' => 'img-test', 'alt' => 'thumbnail test'));


来源:https://stackoverflow.com/questions/4163642/thumbnail-for-uploaded-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!