protected function createImageObject()
    {

        // Check if the file is a valid file
        if ( ! is_file( $this->originalImagePath ) ) {
            throw new Exception( sprintf( '%s: No image found.', $this->originalImagePath ) );
        }

        // Get the mimetype
        $this->imageType = exif_imagetype( $this->originalImagePath );

        // Get the width and height of image
        list($this->width, $this->height) = getimagesize($this->originalImagePath);


        // Create GD object based on the mime type
        switch ( $this->imageType ) {
            case IMAGETYPE_GIF:
                $this->image = imagecreatefromgif( $this->originalImagePath );
                break;

            case IMAGETYPE_PNG:
                $this->image = @imagecreatefrompng( $this->originalImagePath );
                break;

            case IMAGETYPE_JPEG:
                $this->image = @imagecreatefromjpeg( $this->originalImagePath );
                break;

            case IMAGETYPE_BMP:
                $this->image = imagecreatefromwbmp( $this->originalImagePath );
                break;

            // If the image is not one of the previous mimetype
            // We throw an exception
            default:
                throw new Exception( sprintf( 'This MimeType is not supported: %s. Image processed: %s', image_type_to_mime_type( $this->imageType ), $this->originalImagePath ) );
                break;
        }

        // Check if the object is successfully opened
        if( ! $this->image ) {
            throw new Exception( sprintf( 'We could not open this image: %s', $this->originalImagePath ) );
        }

    }