dongqiulei6805
2010-11-12 10:23
浏览 20
已采纳

上传图片的缩略图

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

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

图片转代码服务由CSDN问答提供 功能建议

我正在使用php tp上传图片....我想知道

  • 如何创建图像的缩略图?
  • 如何自定义尺寸和尺寸 比例?
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • doutang1884 2010-11-12 10:32
    已采纳

    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

    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • doulao7998636570 2010-11-12 10:28
    评论
    解决 无用
    打赏 举报
  • dongzhiqi0332 2012-07-18 15:13

    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'));
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题