Watimage API
  • Namespace
  • Class

Namespaces

  • Elboletaire
    • Watimage
      • Exception

Classes

  • Image
  • Normalize
  • Watermark
  • Watimage

Class Watimage

This is a backwards compatibility class. It just has the old Watimage methods and workflow so you can upgrade any project to the new Watimage without changing your code.

Namespace: Elboletaire\Watimage
Copyright: 2015 Òscar Casajuana
License: MIT
Author: Òscar Casajuana Alonso elboletaire@underave.net
Link: https://github.com/elboletaire/Watimage
Located at Watimage.php

Methods summary

public
# __construct( mixed $file = null, mixed $watermark = null )

Construct method. Accepts file and watermark as parameters so you can avoid the setImage and setWatermark methods.

Construct method. Accepts file and watermark as parameters so you can avoid the setImage and setWatermark methods.

Parameters

$file

Image details if is an array, image file location otherwise

$watermark

Watermark details if is an array, watermark file location otherwise.

public Elboletaire\Watimage\Watimage
# setImage( mixed $filename )

Sets image and (optionally) its options

Sets image and (optionally) its options

Parameters

$filename
Filename string or array containing both filename and quality

Returns

Elboletaire\Watimage\Watimage

Throws

Exception
public
# setQuality( integer $quality )

Sets quality for gif and jpg files.

Sets quality for gif and jpg files.

Parameters

$quality
A value from 0 (zero quality) to 100 (max quality).
public
# setCompression( integer $compression )

Sets compression for png files.

Sets compression for png files.

Parameters

$compression
A value from 0 (no compression, not recommended) to 9.
public true
# setWatermark( mixed $options = [] )

Set watermark and (optionally) its options.

Set watermark and (optionally) its options.

Parameters

$options

You can set the watermark without options or you can set an array with any of these $options = [ 'file' => 'watermark.png', 'position' => 'bottom right', // default 'margin' => ['20', '10'] // 0 by default, 'size' => 'full' // 100% by default ];

Returns

true
on success; false on failure
public boolean
# resize( array $options = [] )

Resizes the image.

Resizes the image.

Parameters

$options

= [ 'type' => 'resizemin|resizecrop|resize|crop|reduce', 'size' => ['x' => 2000, 'y' => 500] ] You can also set the size without specifying x and y: [2000, 500]. Or directly 'size' => 2000 (takes 2000x2000)

Returns

boolean
true on success; otherwise false
public boolean
# crop( mixed $options = [] )

Crops an image based on specified coords and size.

Crops an image based on specified coords and size.

Parameters

$options

Specifying x & y position and width & height, like so [ 'x' => 23, 'y' => 23, 'width' => 230, 'height' => 230 ]

Returns

boolean
success
public boolean
# rotateImage( mixed $options = [] )

Rotates an image.

Rotates an image.

Parameters

$options

Can either be an integer with the degrees or an array with keys bgcolor for the rotation bgcolor and degrees for the angle.

Returns

boolean
public
# rotate( $options = [] )

rotateImage alias.

rotateImage alias.

See

Elboletaire\Watimage\Watimage::rotateImage()
public true
# applyWatermark( )

Applies a watermark to the image. Needs to be initialized with $this->setWatermark()

Applies a watermark to the image. Needs to be initialized with $this->setWatermark()

Returns

true
on success, otherwise false
public true
# flip( string $type = 'horizontal' )

Flips an image.

Flips an image.

Parameters

$type
type of flip: horizontal / vertical / both

Returns

true
on success. Otherwise false
public true
# generate( string $path = null, string $output = null )

Generates the image file.

Generates the image file.

Parameters

$path
if not specified image will be printed on screen
$output
mime type for output image (image/png, image/gif, image/jpeg)

Returns

true
on success. Otherwise false

Properties summary

protected Elboletaire\Watimage\Image $image

Image handler.

Image handler.

#
protected Elboletaire\Watimage\Watermark $watermark

Watermark handler.

Watermark handler.

# false
public array $errors

Any error returned by the class will be stored here

Any error returned by the class will be stored here

Public

array $errors
# []
Watimage API API documentation generated by ApiGen