src/Easy/Element/ImageUploader.php
protected function resizeImage($sourceFileName, $destFileName, $width, $height, $quality)
    {
        if (!function_exists("imagejpeg")) {
            return;
        }
        if ($width == 0) {
            $width = $height;
        }

        if ($height == 0) {
            $height = $width;
        }

        list($origWidth, $origHeight) = getimagesize($sourceFileName);

        $origRatio = $origWidth / $origHeight;

        if (($width / $height) > $origRatio) {
            $width = $height * $origRatio;
        } else {
            $height = $width / $origRatio;
        }

        $image_p = imagecreatetruecolor($width, $height);
        try {
            $image = @imagecreatefromjpeg($sourceFileName);
        } catch (Exception $e) {

        }
        try {
            if (!$image) {
                $image = @imagecreatefrompng($sourceFileName);
            }
        } catch (Exception $e) {

        }
        try {
            if (!$image) {
                $image = @imagecreatefromgif($sourceFileName);
            }
        } catch (Exception $e) {

        }
        try {
            if (!$image) {
                $image = @imagecreatefromwbmp($sourceFileName);
            }
        } catch (Exception $e) {

        }

        try {
            if (!$image) {
                $image = @imagecreatefromxbm($sourceFileName);
            }
        } catch (Exception $e) {

        }


        try {
            if (!$image) {
                $image = @imagecreatefromxpm($sourceFileName);
            }
        } catch (Exception $e) {

        }

        if (!$image) {
            return;
        }
        imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $origWidth, $origHeight);

        return imagejpeg($image_p, $destFileName, $quality);
    }
protected function resizeImage($sourceFileName, $destFileName, $width, $height, $quality)
    {
        if (!function_exists("imagejpeg")) {
            return;
        }
        if ($width == 0) {
            $width = $height;
        }

        if ($height == 0) {
            $height = $width;
        }

        list($origWidth, $origHeight) = getimagesize($sourceFileName);

        $origRatio = $origWidth / $origHeight;

        if (($width / $height) > $origRatio) {
            $width = $height * $origRatio;
        } else {
            $height = $width / $origRatio;
        }

        $image_p = imagecreatetruecolor($width, $height);
        try {
            $image = @imagecreatefromjpeg($sourceFileName);
        } catch (Exception $e) {

        }
        try {
            if (!$image) {
                $image = @imagecreatefrompng($sourceFileName);
            }
        } catch (Exception $e) {

        }
        try {
            if (!$image) {
                $image = @imagecreatefromgif($sourceFileName);
            }
        } catch (Exception $e) {

        }
        try {
            if (!$image) {
                $image = @imagecreatefromwbmp($sourceFileName);
            }
        } catch (Exception $e) {

        }

        try {
            if (!$image) {
                $image = @imagecreatefromxbm($sourceFileName);
            }
        } catch (Exception $e) {

        }


        try {
            if (!$image) {
                $image = @imagecreatefromxpm($sourceFileName);
            }
        } catch (Exception $e) {

        }

        if (!$image) {
            return;
        }
        imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $origWidth, $origHeight);

        return imagejpeg($image_p, $destFileName, $quality);
    }
Resize the image     *

@param string $sourceFileName
@param string $destFileName
@param number $width
@param number $height
@param int    $quality <p>
quality is optional, and ranges from 0 (worst
quality, smaller file) to 100 (best quality, biggest file). The
default is the default IJG quality value (about 75).
</p>
@return boolean true is success