The class is designed for PHP version 5.3+, it includes new specifications like namespaces. If you use an older version, like PHP 5.2, it can work until you remove these specifications. See how to install and use the class depending of your PHP version:

PHP 5.3+ with an autoloader

The PHPImageWorkshop folder added in your lib directory, just use the class namespace in your main script and that's it:

        // myscript.php:
        use PHPImageWorkshop\ImageWorkshop;
        
        $layer = new ImageWorkshop(array(...));
        
PHP 5.3+ without autoloader

If you don't use an autoloader, this is a little more tricky but still easy to install: you just need to include files manually.

1 - Include ImageWorkshopException

You have to load ImageWorkshopException class at the beginning of ImageWorkshop file with include() or require_once() functions:

        // ImageWorkshop.php:
        require_once('ImageWorkshopException.php'); // Adapt the correct path, here ImageWorkshopException.php and ImageWorkshop.php are in the same folder
        

If you don't do that, when using ImageWorkshop not correctly, an error like that will be displayed instead of an exception:

        Fatal error: Class 'PHPImageWorkshop\ImageWorkshopException' not found in /home/.../ImageWorkshop.php on line 1731
        
2 - Include ImageWorkshop in your main script

Where you need to use the class don't forget to include it !

        // myscript.php:
        require_once('path/to/lib/PHPImageWorkshop/ImageWorkshop.php'); // Be sure of the path to the class
        
3 - Usage

You can now initialize an object like this:

        // myscript.php:
        $layer = new PHPImageWorkshop\ImageWorkshop(array(...));
        

Alternatively, a better thing is to use the namespace:

        // myscript.php:
        
        use PHPImageWorkshop\ImageWorkshop; // Use the namespace of ImageWorkshop
        
        require_once('path/to/lib/PHPImageWorkshop/ImageWorkshop.php'); // Be sure of the path to the class
        

By this way, you can initialize an object simplier:

        // myscript.php:
        // previous code ...
        
        $layer = new ImageWorkshop(array(...));
        

PHP 5.2 & older versions

Even its not advisable to use ImageWorkshop on an old PHP version, the class can work if you remove all the specifications of 5.3, especially namespaces.

Without clearing files, you will have some parse errors like that:

        Parse error: syntax error, unexpected T_STRING in /home/.../ImageWorkshop.php on line 3
        
        // Or also:
        Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/.../index.php on line 5
        

This is normal: old PHP versions don't recognized namespaces so they consider them as parse errors or illegal characters !

Add PHPImageWorkshop folder in your project and lets do this !

1 - Clear ImageWorkshopException.php file

Remove the namespace declaration line 3:

        namespace PHPImageWorkshop;
        

Remove also the backslash ("\") before Exception line 10:

        class ImageWorkshopException extends \Exception
        
2 - Clear ImageWorkshop.php file

Open ImageWorkshop.php file, and then remove the namespace declaration line 3:

        namespace PHPImageWorkshop;
        

And the namespace inclusion line 5:

        use PHPImageWorkshop\ImageWorkshopException;
        

Then, with your text editor, replace all the founded occurences "static::" by "self::".

And also "new static" by "new self".

This is because late static binding only exists since 5.3 !

3 - Include ImageWorkshopException

You have to load ImageWorkshopException class at the beginning of ImageWorkshop file with include() or require_once() functions:

        // ImageWorkshop.php:
        require_once('ImageWorkshopException.php'); // Adapt the correct path, here ImageWorkshopException.php and ImageWorkshop.php are in the same folder
        

If you don't do that, when using ImageWorkshop not correctly, an error like that will be displayed instead of an exception:

        Fatal error: Class 'PHPImageWorkshop\ImageWorkshopException' not found in /home/.../ImageWorkshop.php on line 1731
        
4 - Include ImageWorkshop in your main script

The last thing, where you need to use the class don't forget to include it !

        // myscript.php:
        require_once('path/to/lib/PHPImageWorkshop/ImageWorkshop.php'); // Be sure of the path to the class
        
5 - Usage

You can now use the class classically:

        // myscript.php:
        $layer = new ImageWorkshop(array(...));