Download the PHP package forgetphp/image-compression without Composer

On this page you can find all versions of the php package forgetphp/image-compression. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package image-compression

PHP JPEG Encoder Project

该项目是基于 libwebp , mozjpeg 实现的。PHP的 gd 库,或者是 imagick 压缩比、性能都不如前者。 如果需要转化成异步模式则需要 Swoole 提供的 Hook 功能将命令转为 CLI 模式。

运行环境

安装

使用

方法

setQuality(int) 设置压缩质量。0-95 默认75

enableAsync() 是否开启异步。依赖 Swoole 提供的 Hook 功能

input(string $image,string $outfile = '') 输入一张图片。第二个参数为输出图片名称,不需要带后缀,不传则使用原名。也可以输入网络图片地址。

inputs(array $images) 输入图片数组。参数说明参考 input()

crop( int $x , int $y , int $width , int $height ) 图片裁切。 x 轴位置 ,y 轴位置 , width 图片宽度 ,height 图片高度

resize( int $width , int $height ) 图片缩放( mozjpeg 不支持), width 图片宽度 ,height 图片高度

output() 输出图片

例子

效果对比

此对比只是针对同一图片而言。不同的图片压缩比会有差异。只能是做一个相对的对比。

原图 Webp mozjpeg imagick(jpg) imagick(webp)
image image image image image
压缩比 85% 83% 52% 72%

兼容

webp兼容一览表

License

MIT


All versions of image-compression with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
hyperf/event Version ^2.0
guzzlehttp/guzzle Version ~6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package forgetphp/image-compression contains the following files

Loading the files please wait ....