protected function _convertFrameToGif($frame_path) { $gif_path = null; // first try with imagemagick convert as imagemaigk produces better gifs if ($this->_config->convert) { $process = new ProcessBuilder('convert', $this->_config); $exec = $process->add($frame_path)->add($frame_path . '.convert-convert.gif')->getExecBuffer(); $exec->setBlocking(true)->execute(); if ($exec->hasError() === true) { throw new Exception('When attempting to convert "' . $frame_path . '" to a gif, convert encountered an error. Convert reported: ' . $exec->getLastLine()); } $gif_path = $frame_path . '.convert-convert.gif'; } // if we still have no gif path then try with php gd. if (empty($gif_path) === true) { if (function_exists('imagegif') === false) { throw new Exception('PHP GD\'s function `imagegif` is not available, as a result the frame could not be added.'); } $im = false; $data = getimagesize($frame_path); switch ($data['mime']) { case 'image/jpeg': $im = @imagecreatefromjpeg($frame_path); break; case 'image/png': $im = @imagecreatefrompng($frame_path); break; case 'image/xbm': $im = @imagecreatefromwbmp($frame_path); break; case 'image/xpm': $im = @imagecreatefromxpm($frame_path); break; } if ($im === false) { throw new Exception('Unsupported image type.'); } // save as a gif $gif_path = $frame_path . '.convert-php.gif'; if (imagegif($im, $gif_path) === false) { throw new Exception('Unable to convert frame to gif using PHP GD.'); } imagedestroy($im); } if (empty($gif_path) === true) { throw new Exception('Unable to convert frame to gif.'); } else { if (is_file($gif_path) === false) { throw new Exception('Unable to convert frame to gif, however the gif conversion path was set.'); } else { if (filesize($gif_path) === 0) { throw new Exception('Unable to convert frame to gif, as a gif was produced, however it was a zero byte file.'); } } } array_push($this->_tidy_up_gifs, $gif_path); return $gif_path; }
/** * 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 */ 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); }
/** * transform source image file (given parameters) and cache result * @param string $src the url of image (myapp/www/):string.[gif|jpeg|jpg|jpe|xpm|xbm|wbmp|png] * @param string image's hashname * @param array $params parameters specifying transformations **/ protected static function transformAndCache($src, $cacheName, $params) { $mimes = array('gif' => 'image/gif', 'png' => 'image/png', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'xpm' => 'image/x-xpixmap', 'xbm' => 'image/x-xbitmap', 'wbmp' => 'image/vnd.wap.wbmp'); global $gJConfig; $srcUri = 'http' . (empty($_SERVER['HTTPS']) ? '' : 's') . '://' . $_SERVER['HTTP_HOST'] . $gJConfig->urlengine['basePath'] . $src; $srcFs = JELIX_APP_WWW_PATH . $src; $path_parts = pathinfo($srcUri); $mimeType = $mimes[strtolower($path_parts['extension'])]; $quality = !empty($params['quality']) ? $params['quality'] : 100; // Creating an image switch ($mimeType) { case 'image/gif': $image = imagecreatefromgif($srcFs); break; case 'image/jpeg': $image = imagecreatefromjpeg($srcFs); break; case 'image/png': $image = imagecreatefrompng($srcFs); break; case 'image/vnd.wap.wbmp': $image = imagecreatefromwbmp($srcFs); break; case 'image/image/x-xbitmap': $image = imagecreatefromxbm($srcFs); break; case 'image/x-xpixmap': $image = imagecreatefromxpm($srcFs); break; default: return; } if (!empty($params['maxwidth']) && !empty($params['maxheight'])) { $origWidth = imagesx($image); $origHeight = imagesy($image); $constWidth = $params['maxwidth']; $constHeight = $params['maxheight']; $ratio = imagesx($image) / imagesy($image); if ($origWidth < $constWidth && $origHeight < $constHeight) { $params['width'] = $origWidth; $params['height'] = $origHeight; } else { $ratioHeight = $constWidth / $ratio; $ratioWidth = $constHeight * $ratio; if ($ratioWidth > $constWidth) { $constHeight = $ratioHeight; } else { if ($ratioHeight > $constHeight) { $constWidth = $ratioWidth; } } $params['width'] = $constWidth; $params['height'] = $constHeight; } } if (!empty($params['width']) || !empty($params['height'])) { $ancienimage = $image; $resampleheight = imagesy($ancienimage); $resamplewidth = imagesx($ancienimage); $posx = 0; $posy = 0; if (empty($params['width'])) { $finalheight = $params['height']; $finalwidth = $finalheight * imagesx($ancienimage) / imagesy($ancienimage); } else { if (empty($params['height'])) { $finalwidth = $params['width']; $finalheight = $finalwidth * imagesy($ancienimage) / imagesx($ancienimage); } else { $finalwidth = $params['width']; $finalheight = $params['height']; if (!empty($params['omo']) && $params['omo'] == 'true') { if ($params['width'] >= $params['height']) { $resampleheight = $resamplewidth * $params['height'] / $params['width']; } else { $resamplewidth = $resampleheight * $params['width'] / $params['height']; } } } } if (!empty($params['zoom'])) { $resampleheight /= 100 / $params['zoom']; $resamplewidth /= 100 / $params['zoom']; } $posx = imagesx($ancienimage) / 2 - $resamplewidth / 2; $posy = imagesy($ancienimage) / 2 - $resampleheight / 2; if (!empty($params['alignh'])) { if ($params['alignh'] == 'left') { $posx = 0; } else { if ($params['alignh'] == 'right') { $posx = -($resamplewidth - imagesx($ancienimage)); } else { if ($params['alignh'] != 'center') { $posx = -$params['alignh']; } } } } if (!empty($params['alignv'])) { if ($params['alignv'] == 'top') { $posy = 0; } else { if ($params['alignv'] == 'bottom') { $posy = -($resampleheight - imagesy($ancienimage)); } else { if ($params['alignv'] != 'center') { $posy = -$params['alignv']; } } } } $image = imagecreatetruecolor($finalwidth, $finalheight); imagesavealpha($image, true); $tp = imagecolorallocatealpha($image, 0, 0, 0, 127); imagefill($image, 0, 0, $tp); imagecopyresampled($image, $ancienimage, 0, 0, $posx, $posy, imagesx($image), imagesy($image), $resamplewidth, $resampleheight); } // The shadow cast adds to the dimension of the image chooses if (!empty($params['shadow'])) { $image = self::createShadow($image, $params); } // Background if (!empty($params['background'])) { $params['background'] = str_replace('#', '', $params['background']); $rgb = array(0, 0, 0); for ($x = 0; $x < 3; $x++) { $rgb[$x] = hexdec(substr($params['background'], 2 * $x, 2)); } $fond = imagecreatetruecolor(imagesx($image), imagesy($image)); imagefill($fond, 0, 0, imagecolorallocate($fond, $rgb[0], $rgb[1], $rgb[2])); imagecopy($fond, $image, 0, 0, 0, 0, imagesx($image), imagesy($image)); $image = $fond; } $cachePath = JELIX_APP_WWW_PATH . 'cache/images/'; jFile::createDir($cachePath); // Register switch ($mimeType) { case 'image/gif': imagegif($image, $cachePath . $cacheName); break; case 'image/jpeg': imagejpeg($image, $cachePath . $cacheName, $quality); break; default: imagepng($image, $cachePath . $cacheName); } // Destruction @imagedestroy($image); }
/** * Returns the GD image resource * * @param *string $data The raw image data * @param *string $path Whether if this raw data is a file path * * @return [RESOURCE] */ protected function createResource($data, $path) { //if the GD Library is not installed if (!function_exists('gd_info')) { //throw error throw ImageException::forGDNotInstalled(); } # imagecreatefromgd — Create a new image from GD file or URL # imagecreatefromgif — Create a new image from file or URL # imagecreatefromjpeg — Create a new image from file or URL # imagecreatefrompng — Create a new image from file or URL # imagecreatefromstring — Create a new image from the image stream in the string # imagecreatefromwbmp — Create a new image from file or URL # imagecreatefromxbm — Create a new image from file or URL # imagecreatefromxpm — Create a new image from file or URL $resource = false; if (!$path) { return imagecreatefromstring($data); } //depending on the extension lets load //the file using the right GD loader switch ($this->type) { case 'gd': $resource = imagecreatefromgd($data); break; case 'gif': $resource = imagecreatefromgif($data); break; case 'jpg': case 'jpeg': case 'pjpeg': $resource = imagecreatefromjpeg($data); break; case 'png': $resource = imagecreatefrompng($data); break; case 'bmp': case 'wbmp': $resource = imagecreatefromwbmp($data); break; case 'xbm': $resource = imagecreatefromxbm($data); break; case 'xpm': $resource = imagecreatefromxpm($data); break; } //if there is no resource still if (!$resource) { //throw error ImageException::forInvalidImageFile($path); } return $resource; }
protected function _getResource($data, $path) { //if the GD Library is not installed if (!function_exists('gd_info')) { //throw error Eden_Image_Error::i(Eden_Image_Error::GD_NOT_INSTALLED)->trigger(); } # imagecreatefromgd — Create a new image from GD file or URL # imagecreatefromgif — Create a new image from file or URL # imagecreatefromjpeg — Create a new image from file or URL # imagecreatefrompng — Create a new image from file or URL # imagecreatefromstring — Create a new image from the image stream in the string # imagecreatefromwbmp — Create a new image from file or URL # imagecreatefromxbm — Create a new image from file or URL # imagecreatefromxpm — Create a new image from file or URL $resource = false; if (!$path) { return imagecreatefromstring($data); } //depending on the extension lets load //the file using the right GD loader switch ($this->_type) { case 'gd': $resource = imagecreatefromgd($data); break; case 'gif': $resource = imagecreatefromgif($data); break; case 'jpg': case 'jpeg': case 'pjpeg': $resource = imagecreatefromjpeg($data); break; case 'png': $resource = imagecreatefrompng($data); break; case 'bmp': case 'wbmp': $resource = imagecreatefromwbmp($data); break; case 'xbm': $resource = imagecreatefromxbm($data); break; case 'xpm': $resource = imagecreatefromxpm($data); break; } //if there is no resource still if (!$resource) { //throw error Eden_Image_Error::i()->setMessage(Eden_Image_Error::NOT_VALID_IMAGE_FILE)->addVariable($path); } return $resource; }
<?php $cwd = dirname(__FILE__); echo "XPM to PNG conversion: "; echo imagepng(imagecreatefromxpm($cwd . "/conv_test.xpm"), $cwd . "/test_xpm.png") ? 'ok' : 'failed'; echo "\n"; @unlink($cwd . "/test_xpm.png");
public static function open($file, $type) { // @rule: Test for JPG image extensions if (function_exists('imagecreatefromjpeg') && ($type == 'image/jpg' || $type == 'image/jpeg' || $type == 'image/pjpeg')) { $im = @imagecreatefromjpeg($file); if ($im !== false) { return $im; } } // @rule: Test for png image extensions if (function_exists('imagecreatefrompng') && ($type == 'image/png' || $type == 'image/x-png')) { $im = @imagecreatefrompng($file); if ($im !== false) { return $im; } } // @rule: Test for png image extensions if (function_exists('imagecreatefromgif') && $type == 'image/gif') { $im = @imagecreatefromgif($file); if ($im !== false) { return $im; } } if (function_exists('imagecreatefromgd')) { # GD File: $im = @imagecreatefromgd($file); if ($im !== false) { return true; } } if (function_exists('imagecreatefromgd2')) { # GD2 File: $im = @imagecreatefromgd2($file); if ($im !== false) { return true; } } if (function_exists('imagecreatefromwbmp')) { # WBMP: $im = @imagecreatefromwbmp($file); if ($im !== false) { return true; } } if (function_exists('imagecreatefromxbm')) { # XBM: $im = @imagecreatefromxbm($file); if ($im !== false) { return true; } } if (function_exists('imagecreatefromxpm')) { # XPM: $im = @imagecreatefromxpm($file); if ($im !== false) { return true; } } // If all failed, this photo is invalid return false; }
function open_image($file) { $im = @imagecreatefromjpeg($file); if ($im !== false) { return $im; } $im = @imagecreatefromgif($file); if ($im !== false) { return $im; } $im = @imagecreatefrompng($file); if ($im !== false) { return $im; } $im = @imagecreatefromgd($file); if ($im !== false) { return $im; } $im = @imagecreatefromgd2($file); if ($im !== false) { return $im; } $im = @imagecreatefromwbmp($file); if ($im !== false) { return $im; } $im = @imagecreatefromxbm($file); if ($im !== false) { return $im; } $im = @imagecreatefromxpm($file); if ($im !== false) { return $im; } $im = @imagecreatefromstring(file_get_contents($file)); if ($im !== false) { return $im; } return false; }
public function createFrom(string $type, string $source, array $settings = NULL) { $type = strtolower($type); switch ($type) { case 'gd2': $return = imagecreatefromgd2($source); break; case 'gd': $return = imagecreatefromgd($source); break; case 'gif': $return = imagecreatefromgif($source); break; case 'jpeg': $return = imagecreatefromjpeg($source); break; case 'png': $return = imagecreatefrompng($source); break; case 'string': $return = imagecreatefromstring($source); break; case 'wbmp': $return = imagecreatefromwbmp($source); break; case 'webp': $return = imagecreatefromwebp($source); break; case 'xbm': $return = imagecreatefromxbm($source); break; case 'xpm': $return = imagecreatefromxpm($source); break; case 'gd2p': $return = imagecreatefromgd2part($source, isset($settings['x']) ? $settings['x'] : NULL, isset($settings['y']) ? $settings['y'] : NULL, isset($settings['width']) ? $settings['width'] : NULL, isset($settings['height']) ? $settings['height'] : NULL); } return $return; }
public function createFrom($type = '', $source = '', $x = '', $y = '', $width = '', $height = '') { if (!is_string($type) || !is_string($source)) { return Error::set(lang('Error', 'stringParameter', '1.(type) & 2.(source)')); } $type = strtolower($type); switch ($type) { case 'gd2': $return = imagecreatefromgd2($source); break; case 'gd': $return = imagecreatefromgd($source); break; case 'gif': $return = imagecreatefromgif($source); break; case 'jpeg': $return = imagecreatefromjpeg($source); break; case 'png': $return = imagecreatefrompng($source); break; case 'string': $return = imagecreatefromstring($source); break; case 'wbmp': $return = imagecreatefromwbmp($source); break; case 'webp': $return = imagecreatefromwebp($source); break; case 'xbm': $return = imagecreatefromxbm($source); break; case 'xpm': $return = imagecreatefromxpm($source); break; case 'gd2p': $return = imagecreatefromgd2part($source, $x, $y, $width, $height); } return $return; }
protected function _getResource($data, $path) { if (!function_exists('gd_info')) { Eden_Image_Error::i(Eden_Image_Error::GD_NOT_INSTALLED)->trigger(); } $resource = false; if (!$path) { return imagecreatefromstring($data); } switch ($this->_type) { case 'gd': $resource = imagecreatefromgd($data); break; case 'gif': $resource = imagecreatefromgif($data); break; case 'jpg': case 'jpeg': case 'pjpeg': $resource = imagecreatefromjpeg($data); break; case 'png': $resource = imagecreatefrompng($data); break; case 'bmp': case 'wbmp': $resource = imagecreatefromwbmp($data); break; case 'xbm': $resource = imagecreatefromxbm($data); break; case 'xpm': $resource = imagecreatefromxpm($data); break; } if (!$resource) { Eden_Image_Error::i()->setMessage(Eden_Image_Error::NOT_VALID_IMAGE_FILE)->addVariable($path); } return $resource; }
public static function isValid( $file ) { require_once(JPATH_SITE.DS.'components'.DS.'com_community'.DS.'libraries'.DS.'core.php'); $config =& CFactory::getConfig(); // Use imagemagick if available $imageEngine = $config->get('imageengine'); $magickPath = $config->get( 'magickPath' ); if( class_exists('Imagick') && ($imageEngine == 'auto' || $imageEngine == 'imagick' ) ) { $thumb = new Imagick(); $imageOk = $thumb->readImage($file); $thumb->destroy(); return $imageOk; } else if( !empty( $magickPath ) && !class_exists( 'Imagick' ) ) { // Execute the command to resize. In windows, the commands are executed differently. if( JString::strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ) { $identifyFile = rtrim( $config->get( 'magickPath' ) , '/' ) . DS . 'identify.exe'; $command = '""' . rtrim( $config->get( 'magickPath' ) , '/' ) . DS . 'identify.exe" -ping "' . $file . '""'; } else { $identifyFile = rtrim( $config->get( 'magickPath' ) , '/' ) . DS . 'identify'; $command = '"' . rtrim( $config->get( 'magickPath' ) , '/' ) . DS . 'identify" -ping "' . $file . '"'; } if( JFile::exists( $identifyFile ) && function_exists( 'exec') ) { $output = exec( $command ); // Test if there's any output, otherwise we know the exec failed. if( !empty( $output ) ) { return true; } } } # JPEG: if( function_exists( 'imagecreatefromjpeg' ) ) { $im = @imagecreatefromjpeg($file); if ($im !== false){ return true; } } if( function_exists( 'imagecreatefromgif' ) ) { # GIF: $im = @imagecreatefromgif($file); if ($im !== false) { return true; } } if( function_exists( 'imagecreatefrompng' ) ) { # PNG: $im = @imagecreatefrompng($file); if ($im !== false) { return true; } } if( function_exists( 'imagecreatefromgd' ) ) { # GD File: $im = @imagecreatefromgd($file); if ($im !== false) { return true; } } if( function_exists( 'imagecreatefromgd2' ) ) { # GD2 File: $im = @imagecreatefromgd2($file); if ($im !== false) { return true; } } if( function_exists( 'imagecreatefromwbmp' ) ) { # WBMP: $im = @imagecreatefromwbmp($file); if ($im !== false) { return true; } } if( function_exists( 'imagecreatefromxbm' ) ) { # XBM: $im = @imagecreatefromxbm($file); if ($im !== false) { return true; } } if( function_exists( 'imagecreatefromxpm' ) ) { # XPM: $im = @imagecreatefromxpm($file); if ($im !== false) { return true; } } // If all failed, this photo is invalid return false; }
/** * Create image ressource from filename. * * @param string Path to the image. * @return void **/ protected function create($filename) { $this->filename = $filename; // if is not a string, not an existing file or not a file ressource if (!is_string($this->filename) || !file_exists($this->filename) || !is_file($this->filename)) { throw new \InvalidArgumentException('Filename is not a valid ressource.'); } switch (exif_imagetype($this->filename)) { case IMAGETYPE_GIF: if (!function_exists('imagecreatefromgif')) { throw new CapabilityException('GIF is not supported.'); } $this->image = imagecreatefromgif($this->filename); break; case IMAGETYPE_JPEG: if (!function_exists('imagecreatefromjpeg')) { throw new CapabilityException('JPEG is not supported.'); } $this->image = imagecreatefromjpeg($this->filename); break; case IMAGETYPE_PNG: if (!function_exists('imagecreatefrompng')) { throw new CapabilityException('PNG is not supported.'); } $this->image = imagecreatefrompng($this->filename); break; case IMAGETYPE_WBMP: if (!function_exists('imagecreatefromwbmp')) { throw new CapabilityException('WBMP is not supported.'); } $this->image = imagecreatefromwbmp($this->filename); break; // Not supported yet in PHP 5.5. WebP is supported since in PHP 5.5 (https://bugs.php.net/bug.php?id=65038) // Not supported yet in PHP 5.5. WebP is supported since in PHP 5.5 (https://bugs.php.net/bug.php?id=65038) case defined('IMAGETYPE_WEBP') && IMAGETYPE_WEBP: if (!function_exists('imagecreatefromwebp')) { throw new CapabilityException('WebP is not supported.'); } $this->image = imagecreatefromwebp($this->filename); break; case IMAGETYPE_XBM: if (!function_exists('imagecreatefromxbm')) { throw new CapabilityException('XBM is not supported.'); } $this->image = imagecreatefromxbm($this->filename); break; case defined('IMAGETYPE_WEBP') && IMAGETYPE_XPM: if (!function_exists('imagecreatefromxpm')) { throw new CapabilityException('XPM is not supported.'); } $this->image = imagecreatefromxpm($this->filename); break; default: throw new CapabilityException('Unsupported input file type.'); break; } $this->setWidth(imagesx($this->image)); $this->setHeight(imagesy($this->image)); }
function showThumb($src, $thumbWidth, $thumbHeight, $dest = "") { $info = pathinfo($src); // load image and get image size //$src = str_replace("%20", "", $src); //$src = "http://google.com"; //echo file_get_contents($src); //exit(); if (strpos($src, "http://" . $_SERVER['HTTP_HOST'] . "/media/") === 0) { $p = urldecode($_GET['p']); $src = str_replace("http://" . $_SERVER['HTTP_HOST'] . "/media/", dirname(__FILE__) . "/", $p); } if ($_GET['showsrc']) { echo $src; exit; } $img = @imagecreatefromjpeg($src); if (!$img) { $img = @imagecreatefrompng($src); } if (!$img) { $img = @imagecreatefromgif($src); } if (!$img) { $img = @imagecreatefromwbmp($src); } if (!$img) { $img = @imagecreatefromgd2($src); } if (!$img) { $img = @imagecreatefromgd2part($src); } if (!$img) { $img = @imagecreatefromgd($src); } if (!$img) { $img = @imagecreatefromstring($src); } if (!$img) { $img = @imagecreatefromxbm($src); } if (!$img) { $img = @imagecreatefromxpm($src); } if (!$img) { return false; } $width = imagesx($img); $height = imagesy($img); $new_width = $width; $new_height = $height; // calculate thumbnail size if ($width > $height) { if ($thumbWidth < $width) { $new_width = $thumbWidth; $new_height = floor($height * ($thumbWidth / $width)); } } else { if ($thumbHeight < $height) { $new_height = $thumbHeight; $new_width = floor($width * ($thumbHeight / $height)); } } if ($_GET['square']) { if ($new_width > $new_height) { $side = $new_width; } else { $side = $new_height; } $tmp_img = imagecreatetruecolor($side, $side); $white = imagecolorallocate($tmp_img, 255, 255, 255); imagefill($tmp_img, 0, 0, $white); imagecopyresampled($tmp_img, $img, ($side - $new_width) / 2, ($side - $new_height) / 2, 0, 0, $new_width, $new_height, $width, $height); } else { // create a new temporary image $tmp_img = imagecreatetruecolor($new_width, $new_height); $white = imagecolorallocate($tmp_img, 255, 255, 255); imagefill($tmp_img, 0, 0, $white); // copy and resize old image into new image imagecopyresampled($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); } if (!trim($dest)) { imagepng($tmp_img, null, 0); } else { @imagepng($tmp_img, $dest, 0); imagepng($tmp_img, null, 0); } // save thumbnail into a file }
function loaddata() { $tmp = explode(".", $this->filename); $ext = strtolower($tmp[count($tmp) - 1]); switch ($ext) { case "bmp": die("Windows BitMaP file not supported."); break; case "gif": $img = imagecreatefromgif($this->filename); break; case "jpg": case "jpeg": $img = imagecreatefromjpeg($this->filename); break; case "png": $img = imagecreatefrompng($this->filename); break; case "xbm": $img = imagecreatefromxbm($this->filename); break; case "xpm": $img = imagecreatefromxpm($this->filename); break; default: die("Invalid / unknown filetype (extension)."); break; } $this->imagewidth = imagesx($img); $this->imageheight = imagesy($img); $y = $this->imageheight; while ($y > 0) { $y--; $this->scanimgline($img, $y, $this->imagewidth, $this->bgcolorrgb); } imagedestroy($img); }
if (function_exists("imagecreatefromwbmp")) { $img = @imagecreatefromwbmp($file); } else { show_plain($file); } break; case '16': if (function_exists("imagecreatefromxbm")) { $img = @imagecreatefromxbm($file); } else { show_plain($file); } break; case 'xpm': if (function_exists("imagecreatefromxpm")) { $img = @imagecreatefromxpm($file); } else { show_plain($file); } break; case 'gd': if (function_exists("imagecreatefromgd")) { $img = @imagecreatefromgd($file); } else { show_plain($file); } break; case 'gd2': if (function_exists("imagecreatefromgd2")) { $img = @imagecreatefromgd2($file); } else {
/** * Create an gd image according to the specified mime type * * @param string $path image file * @param string $mime * @return gd image resource identifier */ protected function gdImageCreate($path, $mime) { switch ($mime) { case 'image/jpeg': return @imagecreatefromjpeg($path); case 'image/png': return @imagecreatefrompng($path); case 'image/gif': return @imagecreatefromgif($path); case 'image/x-ms-bmp': if (!function_exists('imagecreatefrombmp')) { include_once dirname(__FILE__) . '/libs/GdBmp.php'; } return @imagecreatefrombmp($path); case 'image/xbm': return @imagecreatefromxbm($path); case 'image/xpm': return @imagecreatefromxpm($path); } return false; }
if(!class_exists('Eden_Image')){class Eden_Image extends Eden_Class{protected $_resource=NULL;protected $_width=0;protected $_height=0;public static function i(){return self::_getMultiple(__CLASS__);}public function __construct($data,$type=NULL,$path=true,$quality=75){Eden_Image_Error::i()->argument(1,'string')->argument(2,'string','null')->argument(3,'bool')->argument(4,'int');$this->_type=$type;$this->_quality=$quality;$this->_resource=$this->_getResource($data,$path);list($this->_width,$this->_height)=$this->getDimensions();}public function __destruct(){if($this->_resource){imagedestroy($this->_resource);}}public function __toString(){ob_start();switch($this->_type){case 'gif': imagegif($this->_resource);break;case 'png': $quality=(100 - $this->_quality) / 10;if($quality > 9){$quality=9;}imagepng($this->_resource,NULL,$quality);break;case 'bmp': case 'wbmp': imagewbmp($this->_resource,NULL,$this->_quality);break;case 'jpg': case 'jpeg': case 'pjpeg': default: imagejpeg($this->_resource,NULL,$this->_quality);break;}return ob_get_clean();}public function blur(){imagefilter($this->_resource,IMG_FILTER_SELECTIVE_BLUR);return $this;}public function brightness($level){Eden_Image_Error::i()->argument(1,'numeric');imagefilter($this->_resource,IMG_FILTER_BRIGHTNESS,$level);return $this;}public function colorize($red,$blue,$green,$alpha=0){Eden_Image_Error::i()->argument(1,'numeric')->argument(2,'numeric')->argument(3,'numeric')->argument(4,'numeric');imagefilter($this->_resource,IMG_FILTER_COLORIZE,$red,$blue,$green,$alpha);return $this;}public function contrast($level){Eden_Image_Error::i()->argument(1,'numeric');imagefilter($this->_resource,IMG_FILTER_CONTRAST,$level);return $this;}public function crop($width=NULL,$height=NULL){Eden_Image_Error::i()->argument(1,'numeric','null')->argument(2,'numeric','null');$orgWidth=imagesx($this->_resource);$orgHeight=imagesy($this->_resource);if(is_null($width)){$width=$orgWidth;}if(is_null($height)){$height=$orgHeight;}if($width==$orgWidth && $height==$orgHeight){return $this;}$crop=imagecreatetruecolor($width,$height);$xPosition=0;$yPosition=0;if($width > $orgWidth || $height > $orgHeight){$newWidth=$width;$newHeight=$height;if($height > $width){$height=$this->_getHeightAspectRatio($orgWidth,$orgHeight,$width);if($newHeight > $height){$height=$newHeight;$width=$this->_getWidthAspectRatio($orgWidth,$orgHeight,$height);$rWidth=$this->_getWidthAspectRatio($newWidth,$newHeight,$orgHeight);$xPosition=($orgWidth / 2) - ($rWidth / 2);}else{$rHeight=$this->_getHeightAspectRatio($newWidth,$newHeight,$orgWidth);$yPosition=($orgHeight / 2) - ($rHeight / 2);}}else{$width=$this->_getWidthAspectRatio($orgWidth,$orgHeight,$height);if($newWidth > $width){$width=$newWidth;$height=$this->_getHeightAspectRatio($orgWidth,$orgHeight,$width);$rHeight=$this->_getHeightAspectRatio($newWidth,$newHeight,$orgWidth);$yPosition=($orgHeight / 2) - ($rHeight / 2);}else{$rWidth=$this->_getWidthAspectRatio($newWidth,$newHeight,$orgHeight);$xPosition=($orgWidth / 2) - ($rWidth / 2);}}}else{if($width < $orgWidth){$xPosition=($orgWidth / 2) - ($width / 2);$width=$orgWidth;}if($height < $orgHeight){$yPosition=($orgHeight / 2) - ($height / 2);$height=$orgHeight;}}imagecopyresampled($crop,$this->_resource,0,0,$xPosition,$yPosition,$width,$height,$orgWidth,$orgHeight);imagedestroy($this->_resource);$this->_resource=$crop;return $this;}public function edgedetect(){imagefilter($this->_resource,IMG_FILTER_EDGEDETECT);return $this;}public function emboss(){imagefilter($this->_resource,IMG_FILTER_EMBOSS);return $this;}public function gaussianBlur(){imagefilter($this->_resource,IMG_FILTER_GAUSSIAN_BLUR);return $this;}public function getDimensions(){return array(imagesx($this->_resource),imagesy($this->_resource));}public function getResource(){return $this->_resource;}public function greyscale(){imagefilter($this->_resource,IMG_FILTER_GRAYSCALE);return $this;}public function invert($vertical=false){Eden_Image_Error::i()->argument(1,'bool');$orgWidth=imagesx($this->_resource);$orgHeight=imagesy($this->_resource);$invert=imagecreatetruecolor($orgWidth,$orgHeight);if($vertical){imagecopyresampled($invert,$this->_resource,0,0,0,($orgHeight-1),$orgWidth,$orgHeight,$orgWidth,0-$orgHeight);}else{imagecopyresampled($invert,$this->_resource,0,0,($orgWidth-1),0,$orgWidth,$orgHeight,0-$orgWidth,$orgHeight);}imagedestroy($this->_resource);$this->_resource=$invert;return $this;}public function meanRemoval(){imagefilter($this->_resource,IMG_FILTER_MEAN_REMOVAL);return $this;}public function negative(){imagefilter($this->_resource,IMG_FILTER_NEGATE);return $this;}public function resize($width=NULL,$height=NULL){Eden_Image_Error::i()->argument(1,'numeric','null')->argument(2,'numeric','null');$orgWidth=imagesx($this->_resource);$orgHeight=imagesy($this->_resource);if(is_null($width)){$width=$orgWidth;}if(is_null($height)){$height=$orgHeight;}if($width==$orgWidth && $height==$orgHeight){return $this;}$newWidth=$width;$newHeight=$height;if($height < $width){$width=$this->_getWidthAspectRatio($orgWidth,$orgHeight,$height);if($newWidth < $width){$width=$newWidth;$height=$this->_getHeightAspectRatio($orgWidth,$orgHeight,$width);}}else{$height=$this->_getHeightAspectRatio($orgWidth,$orgHeight,$width);if($newHeight < $height){$height=$newHeight;$width=$this->_getWidthAspectRatio($orgWidth,$orgHeight,$height);}}return $this->scale($width,$height);}public function rotate($degree,$background=0){Eden_Image_Error::i()->argument(1,'numeric')->argument(2,'numeric');$rotate=imagerotate($this->_resource,$degree,$background);imagedestroy($this->_resource);$this->_resource=$rotate;return $this;}public function scale($width=NULL,$height=NULL){Eden_Image_Error::i()->argument(1,'numeric','null')->argument(2,'numeric','null');$orgWidth=imagesx($this->_resource);$orgHeight=imagesy($this->_resource);if(is_null($width)){$width=$orgWidth;}if(is_null($height)){$height=$orgHeight;}if($width==$orgWidth && $height==$orgHeight){return $this;}$scale=imagecreatetruecolor($width,$height);imagecopyresampled($scale,$this->_resource,0,0,0,0,$width,$height,$orgWidth,$orgHeight);imagedestroy($this->_resource);$this->_resource=$scale;return $this;}public function setTransparency(){imagealphablending( $this->_resource,false );imagesavealpha( $this->_resource,true );return $this;}public function smooth($level){Eden_Image_Error::i()->argument(1,'numeric');imagefilter($this->_resource,IMG_FILTER_SMOOTH,$level);return $this;}public function save($path,$type=NULL){if(!$type){$type=$this->_type;}switch($type){case 'gif': imagegif($this->_resource,$path);break;case 'png': $quality=(100 - $this->_quality) / 10;if($quality > 9){$quality=9;}imagepng($this->_resource,$path,$quality);break;case 'bmp': case 'wbmp': imagewbmp($this->_resource,$path,$this->_quality);break;case 'jpg': case 'jpeg': case 'pjpeg': default: imagejpeg($this->_resource,$path,$this->_quality);break;}return $this;}protected function _getHeightAspectRatio($sourceWidth,$sourceHeight,$destinationWidth){$ratio=$destinationWidth / $sourceWidth;return $sourceHeight * $ratio;}protected function _getResource($data,$path){if(!function_exists('gd_info')){Eden_Image_Error::i(Eden_Image_Error::GD_NOT_INSTALLED)->trigger();}$resource=false;if(!$path){return imagecreatefromstring($data);}switch($this->_type){case 'gd': $resource=imagecreatefromgd($data);break;case 'gif': $resource=imagecreatefromgif($data);break;case 'jpg': case 'jpeg': case 'pjpeg': $resource=imagecreatefromjpeg($data);break;case 'png': $resource=imagecreatefrompng($data);break;case 'bmp': case 'wbmp': $resource=imagecreatefromwbmp($data);break;case 'xbm': $resource=imagecreatefromxbm($data);break;case 'xpm': $resource=imagecreatefromxpm($data);break;}if(!$resource){Eden_Image_Error::i()->setMessage(Eden_Image_Error::NOT_VALID_IMAGE_FILE)->addVariable($path);}return $resource;}protected function _getWidthAspectRatio($sourceWidth,$sourceHeight,$destinationHeight){$ratio=$destinationHeight / $sourceHeight;return $sourceWidth * $ratio;}}class Eden_Image_Error extends Eden_Error{const GD_NOT_INSTALLED='PHP GD Library is not installed.';const NOT_VALID_IMAGE_FILE='%s is not a valid image file.';const NOT_STRING_MODEL='Argument %d is expecting a string or Eden_Image_Model.';}}
function imageComparison($firstImage, $secondImage) { $firstImageInfo = pathinfo($firstImage); //first image info switch ($firstImageInfo['extension']) { //switch image extension case "jpg": $image = imagecreatefromjpeg($firstImage); break; case "jpeg": $image1 = imagecreatefromjpeg($secondImage); break; case "png": $image = imagecreatefrompng($firstImage); break; case "wbmp": $image = imagecreatefromwbmp($firstImage); break; case "webp": $image = imagecreatefromwebp($firstImage); break; case "xbm": $image = imagecreatefromxbm($firstImage); break; case "xpm": $image = imagecreatefromxpm($firstImage); break; } if (!isset($image)) { //error: not find extension return false; } $width = imagesx($image); //image width $height = imagesy($image); //image height $color = array(); //array color pixel for ($a = 1; $a <= $width; $a++) { for ($b = 1; $b <= $height; $b++) { $color[] = imagecolorat($image, $a, $b); } } $firstComparison = $color; //first image $secondImageInfo = pathinfo($secondImage); switch ($secondImageInfo['extension']) { case "jpg": $image1 = imagecreatefromjpeg($secondImage); break; case "jpeg": $image1 = imagecreatefromjpeg($secondImage); break; case "png": $image1 = imagecreatefrompng($secondImage); break; case "wbmp": $image1 = imagecreatefromwbmp($secondImage); break; case "webp": $image1 = imagecreatefromwebp($secondImage); break; case "xbm": $image1 = imagecreatefromxbm($secondImage); break; case "xpm": $image1 = imagecreatefromxpm($secondImage); break; } if (!isset($image1)) { return false; } $width = imagesx($image1); $height = imagesy($image1); $color1 = array(); for ($a = 1; $a <= $width; $a++) { for ($b = 1; $b <= $height; $b++) { $color1[] = imagecolorat($image1, $a, $b); } } $secondComparison = $color1; //second image $comparison = count($firstComparison); for ($x = 0; $x <= $comparison; $x++) { if ($firstComparison[$x] !== $secondComparison[$x]) { return false; } } }
function resample($width, $height) { if (empty($width) && empty($height)) { return false; } if (empty($this->imageFile) || !file_exists($this->imageFile)) { return false; } // create an image device as image format. switch ($this->getImageType($this->imageFile)) { case "gif": if (imagetypes() & IMG_GIF) { $originImageDevice = imagecreatefromgif($this->imageFile); } else { return false; } break; case "jpg": if (imagetypes() & IMG_JPG) { $originImageDevice = imagecreatefromjpeg($this->imageFile); } else { return false; } break; case "png": if (imagetypes() & IMG_PNG && function_exists('imagecreatefrompng')) { $originImageDevice = imagecreatefrompng($this->imageFile); } else { return false; } break; case "wbmp": if (imagetypes() & IMG_WBMP) { $originImageDevice = imagecreatefromwbmp($this->imageFile); } else { return false; } break; case "xpm": if (imagetypes() & IMG_XPM) { $originImageDevice = imagecreatefromxpm($this->imageFile); } else { return false; } break; default: return false; break; } // 리샘플링은 최종단계에서 리샘플링만을 하는 기능임. 시스템을 예로 들면 OS의 기능에 해당함. // 이미지 프로세스는 어플리케이션의 기능으로 볼 수 있고, 따라서 이미지 리샘플링 중에는 이벤트가 끼어들면 안 됨. //$originImageDevice = fireEvent('BeforeResizeImage', $originImageDevice, $this); if (Path::getExtension($this->imageFile) == ".gif") { $this->resultImageDevice = imagecreate($width, $height); } else { $this->resultImageDevice = imagecreatetruecolor($width, $height); } $temp = imagecolorallocate($this->resultImageDevice, $this->bgColorBy16['R'], $this->bgColorBy16['G'], $this->bgColorBy16['B']); imagefilledrectangle($this->resultImageDevice, 0, 0, $width, $height, $temp); imagecopyresampled($this->resultImageDevice, $originImageDevice, 0, 0, 0, 0, $width, $height, imagesx($originImageDevice), imagesy($originImageDevice)); imagedestroy($originImageDevice); //$this->resultImageDevice = fireEvent('AfterResizeImage', $this->resultImageDevice, $this); return true; }
/** * Open image file */ function _openImage($file) { # JPEG: $im = @imagecreatefromjpeg($file); if ($im !== false) { return $im; } # GIF: $im = @imagecreatefromgif($file); if ($im !== false) { return $im; } # PNG: $im = @imagecreatefrompng($file); if ($im !== false) { return $im; } # GD File: $im = @imagecreatefromgd($file); if ($im !== false) { return $im; } # GD2 File: $im = @imagecreatefromgd2($file); if ($im !== false) { return $im; } # WBMP: $im = @imagecreatefromwbmp($file); if ($im !== false) { return $im; } # XBM: $im = @imagecreatefromxbm($file); if ($im !== false) { return $im; } # XPM: $im = @imagecreatefromxpm($file); if ($im !== false) { return $im; } # Try and load from string: $im = @imagecreatefromstring(file_get_contents($file)); if ($im !== false) { return $im; } }
static function skaluj($file, $max_width, $max_height, $outfile) { list($width, $height, $type) = getimagesize($file); switch ($type) { case IMAGETYPE_JPEG: $image = imagecreatefromjpeg($file); break; case IMAGETYPE_PNG: $image = imagecreatefrompng($file); break; case IMAGETYPE_GIF: $image = imagecreatefromgif($file); break; case IMAGETYPE_XBM: $image = imagecreatefromxpm($file); break; default: error::add('Nieznany format obrazka: ' . $type . '!'); return FALSE; break; } if ($width > $max_width or $height > $max_height) { if ($width * $max_height > $height * $max_width) { $new_width = $max_width; $new_height = round($new_width / $width * $height); } else { $new_height = $max_height; $new_width = round($new_height / $height * $width); } $new_image = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); return imagejpeg($new_image, $outfile, 100); } else { return imagejpeg($image, $outfile, 100); } }
<?php $cwd = dirname(__FILE__); echo "XPM to GD1 conversion: "; echo imagegd(imagecreatefromxpm($cwd . "/conv_test.xpm"), $cwd . "/test.gd1") ? 'ok' : 'failed'; echo "\n"; echo "XPM to GD2 conversion: "; echo imagegd2(imagecreatefromxpm($cwd . "/conv_test.xpm"), $cwd . "/test.gd2") ? 'ok' : 'failed'; echo "\n"; @unlink($cwd . "/test.gd1"); @unlink($cwd . "/test.gd2");
public function input($input) { // if is not a string, not an existing file or not a file ressource if (!is_string($input) || !file_exists($input) || !is_file($input)) { throw new \InvalidArgumentException('Input file is not a valid ressource.'); } $this->inputPath = $input; list($this->inputWidth, $this->inputHeight, $this->inputType) = getimagesize($input); switch ($this->inputType) { case IMAGETYPE_GIF: if (!function_exists('imagecreatefromgif')) { throw new CapabilityException('GIF is not supported.'); } $this->input = imagecreatefromgif($input); break; case IMAGETYPE_JPEG: if (!function_exists('imagecreatefromjpeg')) { throw new CapabilityException('JPEG is not supported.'); } $this->input = imagecreatefromjpeg($input); break; case IMAGETYPE_PNG: if (!function_exists('imagecreatefrompng')) { throw new CapabilityException('PNG is not supported.'); } $this->input = imagecreatefrompng($input); break; case IMAGETYPE_WBMP: if (!function_exists('imagecreatefromwbmp')) { throw new CapabilityException('WBMP is not supported.'); } $this->input = imagecreatefromwbmp($input); break; // Not supported yet in PHP 5.5. WebP is supported since in PHP 5.5 (https://bugs.php.net/bug.php?id=65038) // Not supported yet in PHP 5.5. WebP is supported since in PHP 5.5 (https://bugs.php.net/bug.php?id=65038) case defined('IMAGETYPE_WEBP') && IMAGETYPE_WEBP: if (!function_exists('imagecreatefromwebp')) { throw new CapabilityException('WebP is not supported.'); } $this->input = imagecreatefromwebp($input); break; case IMAGETYPE_XBM: if (!function_exists('imagecreatefromxbm')) { throw new CapabilityException('XBM is not supported.'); } $this->input = imagecreatefromxbm($input); break; case defined('IMAGETYPE_WEBP') && IMAGETYPE_XPM: if (!function_exists('imagecreatefromxpm')) { throw new CapabilityException('XPM is not supported.'); } $this->input = imagecreatefromxpm($input); break; default: throw new CapabilityException('Unsupported input file type.'); break; } $this->applyExifTransformations($this->input); }
/** * transform source image file (given parameters) and store the result into an other file * @param string $srcFs the path to the image to transform. [gif|jpeg|jpg|jpe|xpm|xbm|wbmp|png] * @param string $targetPath the path of the directory to store the resulting image * @param string $targetName the filename of the resulting image * @param array $params parameters specifying transformations */ public static function transformImage($srcFs, $targetPath, $targetName, $params) { $path_parts = pathinfo($srcFs); $mimeType = self::$mimes[strtolower($path_parts['extension'])]; $quality = !empty($params['quality']) ? $params['quality'] : 100; // Creating an image switch ($mimeType) { case 'image/gif': $image = imagecreatefromgif($srcFs); break; case 'image/jpeg': $image = imagecreatefromjpeg($srcFs); break; case 'image/png': $image = imagecreatefrompng($srcFs); break; case 'image/vnd.wap.wbmp': $image = imagecreatefromwbmp($srcFs); break; case 'image/image/x-xbitmap': $image = imagecreatefromxbm($srcFs); break; case 'image/x-xpixmap': $image = imagecreatefromxpm($srcFs); break; default: return; } if (!empty($params['maxwidth']) && !empty($params['maxheight'])) { $origWidth = imagesx($image); $origHeight = imagesy($image); $constWidth = $params['maxwidth']; $constHeight = $params['maxheight']; $ratio = imagesx($image) / imagesy($image); if ($origWidth < $constWidth && $origHeight < $constHeight) { $params['width'] = $origWidth; $params['height'] = $origHeight; } else { $ratioHeight = $constWidth / $ratio; $ratioWidth = $constHeight * $ratio; if ($ratioWidth > $constWidth) { $constHeight = $ratioHeight; } else { if ($ratioHeight > $constHeight) { $constWidth = $ratioWidth; } } $params['width'] = $constWidth; $params['height'] = $constHeight; } } if (!empty($params['width']) || !empty($params['height'])) { $ancienimage = $image; $resampleheight = imagesy($ancienimage); $resamplewidth = imagesx($ancienimage); $posx = 0; $posy = 0; if (empty($params['width'])) { $finalheight = $params['height']; $finalwidth = $finalheight * imagesx($ancienimage) / imagesy($ancienimage); } else { if (empty($params['height'])) { $finalwidth = $params['width']; $finalheight = $finalwidth * imagesy($ancienimage) / imagesx($ancienimage); } else { $finalwidth = $params['width']; $finalheight = $params['height']; if (!empty($params['omo']) && $params['omo'] == 'true') { if ($params['width'] >= $params['height']) { $resampleheight = $resamplewidth * $params['height'] / $params['width']; } else { $resamplewidth = $resampleheight * $params['width'] / $params['height']; } } } } if (!empty($params['zoom'])) { $resampleheight /= 100 / $params['zoom']; $resamplewidth /= 100 / $params['zoom']; } $posx = imagesx($ancienimage) / 2 - $resamplewidth / 2; $posy = imagesy($ancienimage) / 2 - $resampleheight / 2; if (!empty($params['alignh'])) { if ($params['alignh'] == 'left') { $posx = 0; } else { if ($params['alignh'] == 'right') { $posx = -($resamplewidth - imagesx($ancienimage)); } else { if ($params['alignh'] != 'center') { $posx = -$params['alignh']; } } } } if (!empty($params['alignv'])) { if ($params['alignv'] == 'top') { $posy = 0; } else { if ($params['alignv'] == 'bottom') { $posy = -($resampleheight - imagesy($ancienimage)); } else { if ($params['alignv'] != 'center') { $posy = -$params['alignv']; } } } } $image = imagecreatetruecolor($finalwidth, $finalheight); imagesavealpha($image, true); $tp = imagecolorallocatealpha($image, 0, 0, 0, 127); imagecopyresampled($image, $ancienimage, 0, 0, $posx, $posy, imagesx($image), imagesy($image), $resamplewidth, $resampleheight); imagefill($image, 0, 0, $tp); // Because of a strange behavior (ticket #1486), we must fill the background AFTER imagecopyresampled } // The shadow cast adds to the dimension of the image chooses if (!empty($params['shadow'])) { $image = self::createShadow($image, $params); } // Background if (!empty($params['background'])) { $params['background'] = str_replace('#', '', $params['background']); $rgb = array(0, 0, 0); for ($x = 0; $x < 3; $x++) { $rgb[$x] = hexdec(substr($params['background'], 2 * $x, 2)); } $fond = imagecreatetruecolor(imagesx($image), imagesy($image)); imagefill($fond, 0, 0, imagecolorallocate($fond, $rgb[0], $rgb[1], $rgb[2])); imagecopy($fond, $image, 0, 0, 0, 0, imagesx($image), imagesy($image)); $image = $fond; } jFile::createDir($targetPath); // Register switch ($mimeType) { case 'image/gif': imagegif($image, $targetPath . $targetName); break; case 'image/jpeg': imagejpeg($image, $targetPath . $targetName, $quality); break; default: imagepng($image, $targetPath . $targetName); } chmod($targetPath . $targetName, jApp::config()->chmodFile); // Destruction @imagedestroy($image); }
<?php imagecreatefromxpm('', '');