private function _resize($control, $prefix, $width, $height, $preserve_aspect_ratio = true, $method = ZEBRA_IMAGE_BOXED, $background_color = 'FFFFFF', $enlarge_smaller_images = true, $jpeg_quality = 85)
    {

        // if
        if (

            // file was uploaded
            isset($this->file_upload[$control]) &&

            // and file is indeed an image file
            isset($this->file_upload[$control]['imageinfo'])

        ) {

            // if the image transformation class was not already instantiated
            if (!isset($this->Zebra_Image))

                // create a new instance of the image transformation class
                $this->Zebra_Image = new Zebra_Image();

            // set the file permissions as per Zebra_Form's settings
            $this->Zebra_Image->chmod_value = $this->file_upload_permissions;

            // set the source file
            $this->Zebra_Image->source_path = $this->file_upload[$control]['path'] . $this->file_upload[$control]['file_name'];

            // set the target file
            $this->Zebra_Image->target_path = $this->file_upload[$control]['path'] . trim($prefix) . $this->file_upload[$control]['file_name'];

            // set whether aspect ratio should be maintained or not
            $this->Zebra_Image->maintain_ratio = $preserve_aspect_ratio;

            // set the quality of the output image (better quality means bigger file size)
            // available only for jpeg files; ignored for other image types
            $this->Zebra_Image->jpeg_quality = $jpeg_quality;

            // should smaller images be enlarged?
            $this->Zebra_Image->enlarge_smaller_images = $enlarge_smaller_images;

            // if there was an error when resizing the image, return false
            if (!$this->Zebra_Image->resize($width, $height, $method, $background_color)) return false;

        }

        // if the script gets this far, it means that everything went as planned and we return true
        return true;

    }
private function _resize($control, $prefix, $width, $height, $preserve_aspect_ratio = true, $method = ZEBRA_IMAGE_BOXED, $background_color = 'FFFFFF', $enlarge_smaller_images = true, $jpeg_quality = 85)
    {

        // if
        if (

            // file was uploaded
            isset($this->file_upload[$control]) &&

            // and file is indeed an image file
            isset($this->file_upload[$control]['imageinfo'])

        ) {

            // if the image transformation class was not already instantiated
            if (!isset($this->Zebra_Image))

                // create a new instance of the image transformation class
                $this->Zebra_Image = new Zebra_Image();

            // set the file permissions as per Zebra_Form's settings
            $this->Zebra_Image->chmod_value = $this->file_upload_permissions;

            // set the source file
            $this->Zebra_Image->source_path = $this->file_upload[$control]['path'] . $this->file_upload[$control]['file_name'];

            // set the target file
            $this->Zebra_Image->target_path = $this->file_upload[$control]['path'] . trim($prefix) . $this->file_upload[$control]['file_name'];

            // set whether aspect ratio should be maintained or not
            $this->Zebra_Image->maintain_ratio = $preserve_aspect_ratio;

            // set the quality of the output image (better quality means bigger file size)
            // available only for jpeg files; ignored for other image types
            $this->Zebra_Image->jpeg_quality = $jpeg_quality;

            // should smaller images be enlarged?
            $this->Zebra_Image->enlarge_smaller_images = $enlarge_smaller_images;

            // if there was an error when resizing the image, return false
            if (!$this->Zebra_Image->resize($width, $height, $method, $background_color)) return false;

        }

        // if the script gets this far, it means that everything went as planned and we return true
        return true;

    }
private function _resize ( $ control , $ prefix , $ width , $ height , $ preserve_aspect_ratio = true , $ method = ZEBRA_IMAGE_BOXED , $ background_color = 'FFFFFF' , $ enlarge_smaller_images = true , $ jpeg_quality = 85 ) { // if if ( // file was uploaded isset ( $ this -> file_upload [ $ control ] ) && // and file is indeed an image file isset ( $ this -> file_upload [ $ control ] [ 'imageinfo' ] ) ) { // if the image transformation class was not already instantiated if ( ! isset ( $ this -> Zebra_Image ) ) // create a new instance of the image transformation class $ this -> Zebra_Image = new Zebra_Image ( ) ; // set the file permissions as per Zebra_Form's settings $ this -> Zebra_Image -> chmod_value = $ this -> file_upload_permissions ; // set the source file $ this -> Zebra_Image -> source_path = $ this -> file_upload [ $ control ] [ 'path' ] . $ this -> file_upload [ $ control ] [ 'file_name' ] ; // set the target file $ this -> Zebra_Image -> target_path = $ this -> file_upload [ $ control ] [ 'path' ] . trim ( $ prefix ) . $ this -> file_upload [ $ control ] [ 'file_name' ] ; // set whether aspect ratio should be maintained or not $ this -> Zebra_Image -> maintain_ratio = $ preserve_aspect_ratio ; // set the quality of the output image (better quality means bigger file size) // available only for jpeg files; ignored for other image types $ this -> Zebra_Image -> jpeg_quality = $ jpeg_quality ; // should smaller images be enlarged? $ this -> Zebra_Image -> enlarge_smaller_images = $ enlarge_smaller_images ; // if there was an error when resizing the image, return false if ( ! $ this -> Zebra_Image -> resize ( $ width , $ height , $ method , $ background_color ) ) return false ; } // if the script gets this far, it means that everything went as planned and we return true return true ; }
Resize an uploaded image

This method will do nothing if the file is not a supported image file.

@param  string  $control                The file upload control's name

@param  string  $prefix                 If the resized image is to be saved as a new file and the originally
uploaded file needs to be preserved, specify a prefix to be used for the
new file. This way, the resized image will have the same name as the
original file but prefixed with the given value (i.e. "thumb_").

Specifying an empty string as argument will instruct the script to apply
the resizing to the uploaded image and therefore overwriting the
originally uploaded file.

@param  integer $width                  The width to resize the image to.

If set to <b>0</b>, the width will be automatically adjusted, depending
on the value of the <b>height</b> argument so that the image preserves
its aspect ratio.

If <b>preserve_aspect_ratio</b> is set to TRUE and both this and the
<b>height</b> arguments are values greater than <b>0</b>, the image will
be resized to the exact required width and height and the aspect ratio
will be preserved (see the description for the <b>method</b> argument
below on how can this be done).

If <b>preserve_aspect_ratio</b> is set to FALSE, the image will be
resized to the required width and the aspect ratio will be ignored.

If both <b>width</b> and <b>height</b> are set to <b>0</b>, a copy of
the source image will be created (<b>jpeg_quality</b> will still apply).

If either <b>width</b> or <b>height</b> are set to <b>0</b>, the script
will consider the value of the {@link preserve_aspect_ratio} to bet set
to TRUE regardless of its actual value!

@param  integer $height                 The height to resize the image to.

If set to <b>0</b>, the height will be automatically adjusted, depending
on the value of the <b>width</b> argument so that the image preserves
its aspect ratio.

If <b>preserve_aspect_ratio</b> is set to TRUE and both this and the
<b>width</b> arguments are values greater than <b>0</b>, the image will
be resized to the exact required width and height and the aspect ratio
will be preserved (see the description for the <b>method</b> argument
below on how can this be done).

If <b>preserve_aspect_ratio</b> is set to FALSE, the image will be
resized to the required height and the aspect ratio will be ignored.

If both <b>height</b> and <b>width</b> are set to <b>0</b>, a copy of
the source image will be created (<b>jpeg_quality</b> will still apply).

If either <b>height</b> or <b>width</b> are set to <b>0</b>, the script
will consider the value of the {@link preserve_aspect_ratio} to bet set
to TRUE regardless of its actual value!

@param  boolean $preserve_aspect_ratio  (Optional) If set to TRUE, the image will be resized to the given width
and height and the aspect ratio will be preserved.

Set this to FALSE if you want the image forcefully resized to the exact
dimensions given by width and height ignoring the aspect ratio

Default is TRUE.

@param  int     $method                 (Optional) Method to use when resizing images to exact width and height
while preserving aspect ratio.

If the $preserve_aspect_ratio property is set to TRUE and both the
<b>width</b> and <b>height</b> arguments are values greater than <b>0</b>,
the image will be resized to the exact given width and height and the
aspect ratio will be preserved by using on of the following methods:

-   <b>ZEBRA_IMAGE_BOXED</b> - the image will be scaled so that it will
fit in a box with the given width and height (both width/height will
be smaller or equal to the required width/height) and then it will
be centered both horizontally and vertically. The blank area will be
filled with the color specified by the <b>$background_color</b>
argument. (the blank area will be filled only if the image is not
transparent!)

-   <b>ZEBRA_IMAGE_NOT_BOXED</b> - the image will be scaled so that it
<i>could</i> fit in a box with the given width and height but will
not be enclosed in a box with given width and height. The new width/
height will be both smaller or equal to the required width/height

-   <b>ZEBRA_IMAGE_CROP_TOPLEFT</b>
-   <b>ZEBRA_IMAGE_CROP_TOPCENTER</b>
-   <b>ZEBRA_IMAGE_CROP_TOPRIGHT</b>
-   <b>ZEBRA_IMAGE_CROP_MIDDLELEFT</b>
-   <b>ZEBRA_IMAGE_CROP_CENTER</b>
-   <b>ZEBRA_IMAGE_CROP_MIDDLERIGHT</b>
-   <b>ZEBRA_IMAGE_CROP_BOTTOMLEFT</b>
-   <b>ZEBRA_IMAGE_CROP_BOTTOMCENTER</b>
-   <b>ZEBRA_IMAGE_CROP_BOTTOMRIGHT</b>

For the methods involving crop, first the image is scaled so that both
its sides are equal or greater than the respective sizes of the bounding
box; next, a region of required width and height will be cropped from
indicated region of the resulted image.

Default is ZEBRA_IMAGE_BOXED

@param  boolean $background_color       (Optional) The hexadecimal color of the blank area (without the #).
See the <b>method</b> argument.

Default is 'FFFFFF'

@param  boolean $enlarge_smaller_images (Optional) If set to FALSE, images having both width and height smaller
than the required width and height, will be left untouched ({@link jpeg_quality}
will still apply).

Default is TRUE

@param  boolean $quality                (Optional) Indicates the quality of the output image (better quality
means bigger file size).

Range is 0 - 100

Available only for JPEG files.

Default is 85

@return boolean                         Returns TRUE on success or FALSE otherwise

@access private
Resize an uploaded image