Watimage Exceptions Usage

Reading time ~4 minutes

Watimage uses 5 custom exception classes that extend from php’s Exception.

  • ExtensionNotLoadedException
  • FileNotExistException
  • InvalidArgumentException
  • InvalidExtensionException
  • InvalidMimeException

Knowing that, you can catch exceptions one by one:

use Elboletaire\Watimage\Exception\ExtensionNotLoadedException;
use Elboletaire\Watimage\Exception\FileNotExistException;
use Elboletaire\Watimage\Exception\InvalidArgumentException;
use Elboletaire\Watimage\Exception\InvalidExtensionException;
use Elboletaire\Watimage\Exception\InvalidMimeException;

try {

} catch (ExtensionNotLoadedException $e) {
} catch (FileNotExistException $e) {
} catch (InvalidArgumentException $e) {
} catch (InvalidExtensionException $e) {
} catch (InvalidMimeException $e) {
}

Or just catch from Exception:

use Exception;

try {

} catch (Exception $e) {
}

← Go back to Watimage Classes Usage

About the header image

For the header image the following code has been executed:

$image = new Image('freeparty-back.jpg');
$image
    ->contrast(-5)
    ->brightness(-60)
    ->colorize(['r' => 100, 'g' => 70, 'b' => 50, 'a' => 0])
    ->brightness(-35)
    ->contrast(-5)
    ->colorize(['r' => 0, 'g' => 5, 'b' => 15, 'a' => 0])
    ->vignette(.1)
    ->generate()
;

Both the image and the original can be found under gh-pages branch, inside images folder.