Download the PHP package gumlet/php-image-resize without Composer

On this page you can find all versions of the php package gumlet/php-image-resize. 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 php-image-resize

php-image-resize

PHP library to resize, scale and crop images.

Build Status Latest Stable Version Monthly Downloads Coverage Status

Cloud Solution

If you don't want to crop, resize and store images on your server, Gumlet.com is a free service which can process images in real-time and serve worldwide through CDN.


Setup

This package is available through Packagist with the vendor and package identifier the same as this repo.

If using Composer, in your composer.json file add:

If you are still using PHP 5.3, please install version and if you are using PHP 5.4, please install version of this library.

WebP support is added with PHP 5.6.0 and current version of library supports that. If you are facing issues, please use 1.9.2 version of this library.

For PHP versions >= 7.2, 2.0.1 or above version of this library should be used.

Otherwise:

Because this class uses namespacing, when instantiating the object, you need to either use the fully qualified namespace:

Or alias it:

Note: This library uses GD class which do not support resizing animated gif files


Resize

To scale an image, in this case to half it's size (scaling is percentage based):

To resize an image according to one dimension (keeping aspect ratio):

To resize an image according to a given measure regardingless its orientation (keeping aspect ratio):

To resize an image to best fit a given set of dimensions (keeping aspet ratio):

All resize functions have option which is set to false by default. You can enable by passing to any resize function:

If you are happy to handle aspect ratios yourself, you can resize directly:

This will cause your image to skew if you do not use the same width/height ratio as the source image.

Crop

To to crop an image:

This will scale the image to as close as it can to the passed dimensions, and then crop and center the rest.

In the case of the example above, an image of 400px × 600px will be resized down to 200px × 300px, and then 50px will be taken off the top and bottom, leaving you with 200px × 200px.

Crop modes:

Few crop mode options are available in order for you to choose how you want to handle the eventual exceeding width or height after resizing down your image. The default crop mode used is the CROPCENTER. As a result those pieces of code are equivalent:

In the case you have an image of 400px × 600px and you want to crop it to 200px × 200px the image will be resized down to 200px × 300px, then you can indicate how you want to handle those 100px exceeding passing the value of the crop mode you want to use.

For instance passing the crop mode CROPTOP will result as 100px taken off the bottom leaving you with 200px × 200px.

On the contrary passing the crop mode CROPBOTTOM will result as 100px taken off the top leaving you with 200px × 200px.

Freecrop:

There is also a way to define custom crop position. You can define $x and $y in method:

Loading and saving images from string

To load an image from a string:

You can also return the result as a string:

Magic __toString() is also supported:

Displaying

As seen above, you can call $image->save('image.jpg');

To render the image directly into the browser, you can call $image->output();

Image Types

When saving to disk or outputting into the browser, the script assumes the same output type as input.

If you would like to save/output in a different image type, you need to pass a (supported) PHP IMAGETYPE_* constant:

This allows you to save in a different type to the source:

Quality

The properties $quality_jpg, $quality_webp and $quality_png are available for you to configure:

By default they are set to 85 and 6 respectively. See the manual entries for imagejpeg() and imagepng() for more info.

You can also pass the quality directly to the save(), output() and getImageAsString() methods:

We're passing null for the image type in the example above to skip over it and provide the quality. In this case, the image type is assumed to be the same as the input.

Interlacing

By default, image interlacing is turned on. It can be disabled by setting $interlace to 0:

Chaining

When performing operations, the original image is retained, so that you can chain operations without excessive destruction.

This is useful for creating multiple sizes:

Exceptions

ImageResize throws ImageResizeException for it's own for errors. You can catch that or catch the general \Exception which it's extending.

It is not to be expected, but should anything go horribly wrong mid way then notice or warning Errors could be shown from the PHP GD and Image Functions (http://php.net/manual/en/ref.image.php)

Filters

You can apply special effects for new image like blur or add banner.

Flip

Flips an image using a given mode and this method is only for PHP version 5.4.

Both functions will be used in the order in which they were added.

Gamma color correction

You can enable the gamma color correction which is disabled by default.

API Doc

https://gumlet.github.io/php-image-resize/index.html


Maintainer

This library is maintained by Gumlet.com


All versions of php-image-resize with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
ext-gd Version *
ext-fileinfo Version *
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 gumlet/php-image-resize contains the following files

Loading the files please wait ....