Zebra_Image::_write_image PHP Method

_write_image() private method

@param $identifier identifier An image identifier
private _write_image ( $identifier ) : boolean
return boolean Returns TRUE on success or FALSE on error. If FALSE is returned, check the {@link error} property to see the error code. @access private
    private function _write_image($identifier)
    {
        // sharpen image if it's required
        $this->_sharpen_image($identifier);
        // image saving process goes according to required extension
        switch ($this->target_type) {
            // if GIF
            case 'gif':
                // if GD support for this file type is not available
                // in version 1.6 of GD the support for GIF files was dropped see
                // http://php.net/manual/en/function.imagegif.php#function.imagegif.notes
                if (!function_exists('imagegif')) {
                    // save the error level and stop the execution of the script
                    $this->error = 6;
                    return false;
                    // if, for some reason, file could not be created
                } elseif (@(!imagegif($identifier, $this->target_path))) {
                    // save the error level and stop the execution of the script
                    $this->error = 3;
                    return false;
                }
                break;
                // if JPEG
            // if JPEG
            case 'jpg':
            case 'jpeg':
                // if GD support for this file type is not available
                if (!function_exists('imagejpeg')) {
                    // save the error level and stop the execution of the script
                    $this->error = 6;
                    return false;
                    // if, for some reason, file could not be created
                } elseif (@(!imagejpeg($identifier, $this->target_path, $this->jpeg_quality))) {
                    // save the error level and stop the execution of the script
                    $this->error = 3;
                    return false;
                }
                break;
                // if PNG
            // if PNG
            case 'png':
                // save full alpha channel information
                imagesavealpha($identifier, true);
                // if GD support for this file type is not available
                if (!function_exists('imagepng')) {
                    // save the error level and stop the execution of the script
                    $this->error = 6;
                    return false;
                    // if, for some reason, file could not be created
                } elseif (@(!imagepng($identifier, $this->target_path, $this->png_compression))) {
                    // save the error level and stop the execution of the script
                    $this->error = 3;
                    return false;
                }
                break;
                // if not a supported file extension
            // if not a supported file extension
            default:
                // save the error level and stop the execution of the script
                $this->error = 5;
                return false;
        }
        // get a list of functions disabled via configuration
        $disabled_functions = @ini_get('disable_functions');
        // if the 'chmod' function is not disabled via configuration
        if ($disabled_functions == '' || strpos('chmod', $disabled_functions) === false) {
            // chmod the file
            chmod($this->target_path, intval($this->chmod_value, 8));
            // save the error level
        } else {
            $this->error = 8;
        }
        // if target file has to have the same timestamp as the source image
        if ($this->preserve_time && isset($this->source_image_time)) {
            // touch the newly created file
            @touch($this->target_path, $this->source_image_time);
        }
        // return true
        return true;
    }