PHPackages                             ride/lib-image - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. ride/lib-image

ActiveLibrary[Image &amp; Media](/categories/media)

ride/lib-image
==============

Image processing library of the Ride framework

1.0.2(6y ago)05.6k9MITPHP

Since Nov 7Pushed 6y ago8 watchersCompare

[ Source](https://github.com/all-ride/ride-lib-image)[ Packagist](https://packagist.org/packages/ride/lib-image)[ RSS](/packages/ride-lib-image/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (24)Used By (9)

Ride: Image Library
===================

[](#ride-image-library)

Image processing library of the PHP Ride framework.

You need GD or Imagick on your server to use this library.

What's In This Library
----------------------

[](#whats-in-this-library)

### Image

[](#image)

The *Image* interface is the base of this library.

Through this interface, you can:

- read and write images
- get information about your image like the dimension
- basic manipulations like resizing and cropping

The *DrawImage* interface extends from *Image* and adds methods to draw points, lines, ... on the image.

Implementations are available for GD and Imagick.

### ImageFactory

[](#imagefactory)

The *ImageFactory* interface offers a generic way to create the instances needed to work with images.

A generic implementation is provided through *GenericImageFactory*.

### Point

[](#point)

The *Point* interface is to define a coordinate on an X-Y axis. It's used for image manipulations. A point can go positive or negative on an axis.

A generic implementation is provided through *GenericPoint*.

### Dimansion

[](#dimansion)

The *Dimension* interface defines a dimension of an image or manipulation.

A generic implementation is provided through *GenericDimension*.

### Transformation

[](#transformation)

The *Transformation* interface offers a way to apply batch image manipulations.

There are implementations available for crop, resize, flip, blur, grayscale, watermark and chain manipulations.

#### Blur

[](#blur)

Blurs your image.

This transformation has following options:

- radius: optional and defaults to 10

#### Crop

[](#crop)

Crops your image by resizing it first to an optimal dimension.

This transformation requires the following options:

- width: width to crop to in pixels
- height: height to crop to in pixels

#### Flip

[](#flip)

Flips your image over the X-axis and/or the Y-axis.

This transformation requires the following options:

- mode: can be horizontal, vertical or both.

#### Grayscale

[](#grayscale)

Converts your image to a grayscaled image.

This transformations has no options.

#### Resize

[](#resize)

Resizes your image to fit a maximum width and/or height.

This transformation requires one of the following options:

- width: maximum width of the resulting image
- height: maximum height of the resulting image

#### Watermark

[](#watermark)

Adds a watermark to your image.

This transformation has the following options:

- x: Point on the X-axis, defaults to 0
- y: Point on the Y-axis, defaults to 0
- watermark: relative path to the watermark image

### Optimizer

[](#optimizer)

The *Optimizer* interface can be used to implement optimalizations on image files. It's intented to optimize the file sizes but can be used for other purposes as well.

A generic implementation is provided through *GenericOptimizer*.

#### GenericOptimizer

[](#genericoptimizer)

The generic image optimizer uses the following binaries on your system:

- pngcrush
- optipng
- jpegoptim
- jpegtran (libjpeg-turbo-progs or libjpeg-progs)
- gifsicle

*Note: Unexistant binaries are ignored.*

#### NullOptimizer

[](#nulloptimizer)

No optimization is performed by this optimizer.

### Color

[](#color)

The *Color* interface offers an easy way to work with colors.

The interface is currently implemented for the RGB and the HSL color model.

### ColorScheme

[](#colorscheme)

The *ColorScheme* interface is to generate a number of colors for a specified base color.

The interface is currently implemented for monochomatic and complementary schemes.

Code Sample
-----------

[](#code-sample)

Check this code sample to see the possibilities of this library:

```
