本文整理汇总了PHP中imagecreatefromxpm函数的典型用法代码示例。如果您正苦于以下问题:PHP imagecreatefromxpm函数的具体用法?PHP imagecreatefromxpm怎么用?PHP imagecreatefromxpm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagecreatefromxpm函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _convertFrameToGif
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;
}
开发者ID:ravinderphp,项目名称:landlordv2,代码行数:58,代码来源:AnimatedGifTranscoderGifsicle.php
示例2: resizeImage
/**
* 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);
}
开发者ID:openbizx,项目名称:openbizx,代码行数:73,代码来源:ImageUploader.php
示例3: transformAndCache
/**
* 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') {
//.........这里部分代码省略.........
开发者ID:Calmacil,项目名称:ffdvh,代码行数:101,代码来源:jImageModifier.class.php
示例4: createResource
/**
* 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;
}
开发者ID:cradlephp,项目名称:packages,代码行数:62,代码来源:ImageHandler.php
示例5: _getResource
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;
}
开发者ID:annaqin,项目名称:eden,代码行数:54,代码来源:image.php
示例6: dirname
<?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");
开发者ID:gleamingthecube,项目名称:php,代码行数:7,代码来源:ext_gd_tests_xpm2png.php
示例7: open
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;
}
开发者ID:bizanto,项目名称:Hooked,代码行数:61,代码来源:image.php
示例8: open_image
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;
}
开发者ID:madr,项目名称:urban-octo-rotary-phone,代码行数:40,代码来源:common.php
示例9: createFrom
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;
}
开发者ID:znframework,项目名称:znframework,代码行数:39,代码来源:InternalGD.php
示例10: createFrom
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;
}
开发者ID:Allopa,项目名称:ZN-Framework-Starter,代码行数:42,代码来源:GD.php
示例11: _getResource
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;
}
开发者ID:jpalala,项目名称:startupjobs,代码行数:40,代码来源:eden.php
示例12: isValid
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; }
}
//.........这里部分代码省略.........
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:101,代码来源:register.jomsocial.php
示例13: create
/**
* 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));
}
开发者ID:moust,项目名称:paint,代码行数:65,代码来源:Image.php
示例14: showThumb
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
}
开发者ID:juslee,项目名称:e27,代码行数:89,代码来源:image.php
示例15: loaddata
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);
}
开发者ID:jens-wetzel,项目名称:use2,代码行数:37,代码来源:picture.php
示例16: show_plain
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 {
开发者ID:neymanna,项目名称:fusionforge,代码行数:31,代码来源:ImageTile.php
示例17: gdImageCreate
/**
* 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;
}
开发者ID:lalusaud,项目名称:mysite,代码行数:28,代码来源:elFinderVolumeDriver.class.php
示例18:
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);brea
|
请发表评论