承接 innobotics/imageresize 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

innobotics/imageresize

Composer 安装命令:

composer require innobotics/imageresize

包简介

PHP class to resize images

README 文档

README

Install

You can install ImageResize by composer. Add this row to your composer.json.

{
    "require": {
        "Innobotics/ImageResize": "1.*"
    }
}

But do you want to include this pack use this:

require_once '/path/to/Innobotics/ImageResize.php';

Usage

You should create an image object.

$image = new \Innobotics\ImageResize();

Add types. The type contains the key, and the image's size.

$image->setType('large', 640, 480);
$image->setType('medium', 320, 240);
$image->setType('thumbnail', 160, 120);
$image->setType('content', 500, null); // You can add 'null' as height. It won't be cropped.

Add the source file.

$image->setSource('/home/notesz/teszt/bianka_160117.jpg');

Add the target folder.

$image->setTarget('/home/notesz/teszt/resized');

If you don't like the original name, you can add a new filename. (It is optional)

$image->setFileName('bianka.jpg'); //optional

Would you like to set compression? Add this one: (It is optional, the default value is 75)

$image->setCompression(100); //optional

Would you like to set compression type? Add this one: (It is optional, the default value is 9) You can find types here: https://www.geeksforgeeks.org/php-imagick-setimagecompression-function/

$image->setCompressionType(8); //optional

Would you like to use a file prefix? Add this one: (It is optional)

$image->setPrefix('image'); //optional

Would you like to disable progressive (setInterlace)? Add this one: (It is optional)

$image->setProgressive(false); //optional

Would you like to use retina sizes? Add this one: (It is optional)

$image->setRetina(true); //optional

If you don't want to save the original image you can disable it. Add this one: (It is optional)

$image->setSaveOriginal(false); //optional

Resize your image.

if ($image->resize() === true) {
    print 'It\s okay! :)';
} else {
    print 'Something happened!';
}

Then you can reach the result.

print_r($image->getResult());

If the resize was success, the result is:

Array
(
    [status] => success
    [message] => Array
        (
            [files] => Array
                (
                    [large] => image_bianka_large.jpg
                    [medium] => image_bianka_medium.jpg
                    [thumbnail] => image_bianka_thumbnail.jpg
                    [original] => image_bianka.jpg
                )

        )

)

But the resize was false, the result is:

Array
(
    [status] => error
    [message] => unable to open image `/home/notesz/teszt/IMG_790s7.jpg': No such file or directory @ error/blob.c/OpenBlob/2638
)

统计信息

  • 总下载量: 114
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-04-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固