承接 lexinzector/picture 相关项目开发

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

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

lexinzector/picture

最新稳定版本:1.0

Composer 安装命令:

composer require lexinzector/picture

包简介

Library for working with images (cropping and reducing, converting to base64, etc.)

README 文档

README

Library for working with images (cropping and reducing, converting to base64, etc.)

Possibilities

  • proportionally reduce the image size in width or height
  • reduce the image by percentage
  • fit the image into a frame of a certain size
  • arbitrary image resizing
  • change image quality
  • output the generated image without saving
  • saving the image on the server
  • assigning access rights to the image

Requirements

PHP >= 5.6.0

Installation

run in console:

composer require lexinzector/picture

Example

use \Lexinzector\Picture\Picture;

// resize the image proportionally and save it on the server without changing the file extension
// the resulting image will not exceed 400 pixels in height and 300 in width
// that is, it will automatically fit into the required dimensions
$new_image = new Picture('url or path to file');
$new_image->autoimageresize(300, 400);
$new_image->imagesave($new_image->image_type, 'folder on the server');
$new_image->imageout();

// output to the screen without changing the file extension
$new_image = new Picture('url or path to file');
$new_image->autoimageresize(300, 400);
$new_image->imagesave($new_image->image_type, null);
$new_image->imageout();

// save on the server and select the output file type
$new_image = new Picture('url or path to file');
$new_image->autoimageresize(300, 400);
$new_image->imagesave('png', 'folder on the server');
$new_image->imageout();

// compress the file and display it on the screen
$new_image = new Picture('url or path to file');
$new_image->autoimageresize(300, 400);
$new_image->imagesave('jpeg', null, 75);
$new_image->imageout();

// save on the server, compress and set access rights
$new_image = new Picture('url or path to file');
$new_image->autoimageresize(300, 400);
$new_image->imagesave('jpeg', 'folder on the server', 75, 0777);
$new_image->imageout();

// reduce the image width
$new_image = new Picture('url or path to file');
$new_image->imageresizewidth(300);
$new_image->imagesave($new_image->image_type, 'folder on the server');
$new_image->imageout();

// reduce the image height
$new_image = new Picture('url or path to file');
$new_image->imageresizeheight(400);
$new_image->imagesave($new_image->image_type, 'folder on the server');
$new_image->imageout();

// arbitrarily reduce the image without maintaining the proportions
$new_image = new Picture('url or path to file');
$new_image->imageresize(300, 400);
$new_image->imagesave($new_image->image_type, 'folder on the server');
$new_image->imageout();

// reduce the image by percentage
$new_image = new Picture('url or path to file');
$new_image->percentimagereduce(30);
$new_image->imagesave($new_image->image_type, 'folder on the server');
$new_image->imageout();

// reduce the image without maintaining the proportions without saving the image on disk for output in base64 format
$new_image = new Picture('url or path to file');
$new_image->imageresize(300, 400);
$new_image->imagesave($new_image->image_type, 'out');
$new_image->imageout();
$dataUri = "data:image/jpeg;base64,".base64_encode($new_image->image_contents);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-10-17