public static function resizeAndSave($dir, $fileName, $resizeWidth)
    {
        $DS = DIRECTORY_SEPARATOR;

        // Full original image path
        $fullPath = $dir . $DS . $fileName;

        if (!@file_exists($fullPath)) {
            // if original file doesn't exists - breack
            return false;
        }

        try {
            $imageComponent = static::getImageComponent();
            $image_r = $imageComponent->load($fullPath);
            /* @var $image_r Image_GD|Image_Imagick */
            if (is_array($resizeWidth)) {
                foreach ($resizeWidth as $prefix => $width) {
                    $image_r->resize($width, static::getMaxHeight($width));
                    $image_r->save($dir . $DS . $prefix . $fileName);
                }
            } else {
                $image_r->resize($resizeWidth, static::getMaxHeight($resizeWidth));
                $image_r->save($fullPath);
            }
        } catch (\Exception $e) {
            return false;
        }

        return true;
    }
public static function resizeAndSave($dir, $fileName, $resizeWidth)
    {
        $DS = DIRECTORY_SEPARATOR;

        // Full original image path
        $fullPath = $dir . $DS . $fileName;

        if (!@file_exists($fullPath)) {
            // if original file doesn't exists - breack
            return false;
        }

        try {
            $imageComponent = static::getImageComponent();
            $image_r = $imageComponent->load($fullPath);
            /* @var $image_r Image_GD|Image_Imagick */
            if (is_array($resizeWidth)) {
                foreach ($resizeWidth as $prefix => $width) {
                    $image_r->resize($width, static::getMaxHeight($width));
                    $image_r->save($dir . $DS . $prefix . $fileName);
                }
            } else {
                $image_r->resize($resizeWidth, static::getMaxHeight($resizeWidth));
                $image_r->save($fullPath);
            }
        } catch (\Exception $e) {
            return false;
        }

        return true;
    }
public static function resizeAndSave ( $ dir , $ fileName , $ resizeWidth ) { $ DS = DIRECTORY_SEPARATOR ; // Full original image path $ fullPath = $ dir . $ DS . $ fileName ; if ( ! @ file_exists ( $ fullPath ) ) { // if original file doesn't exists - breack return false ; } try { $ imageComponent = static :: getImageComponent ( ) ; $ image_r = $ imageComponent -> load ( $ fullPath ) ; /* @var $image_r Image_GD|Image_Imagick */ if ( is_array ( $ resizeWidth ) ) { foreach ( $ resizeWidth as $ prefix => $ width ) { $ image_r -> resize ( $ width , static :: getMaxHeight ( $ width ) ) ; $ image_r -> save ( $ dir . $ DS . $ prefix . $ fileName ) ; } } else { $ image_r -> resize ( $ resizeWidth , static :: getMaxHeight ( $ resizeWidth ) ) ; $ image_r -> save ( $ fullPath ) ; } } catch ( \ Exception $ e ) { return false ; } return true ; }
Make resized images

@param string $dir        Random directory path
@param string $fileName   Primary filename
@param mixed $resizeWidth integer(wide): one resize - rewrite primary file.<br />
array: resize for each item.<br />
array format:
<pre>
array('prefix1'=>sizeWidth1, 'prefix2'=>sizeWidth2)
</pre>

@return boolean TRUE if successfull, FALSE otherwise
@todo Crop max height instead validaton error message?
Make resized images