本文整理汇总了PHP中getImageSize函数的典型用法代码示例。如果您正苦于以下问题:PHP getImageSize函数的具体用法?PHP getImageSize怎么用?PHP getImageSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getImageSize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: imageAction
public function imageAction()
{
$request = $this->getRequest();
$response = $this->getResponse();
$id = (int) $request->getQuery('id');
$w = (int) $request->getQuery('w');
$h = (int) $request->getQuery('h');
$hash = $request->getQuery('hash');
$realHash = DatabaseObject_BlogPostImage::GetImageHash($id, $w, $h);
$this->_helper->viewRenderer->setNoRender();
$image = new DatabaseObject_BlogPostImage($this->db);
if ($hash != $realHash || !$image->load($id)) {
$response->setHttpResponseCode(404);
return;
}
try {
$fullpath = $image->createThumbnail($w, $h);
} catch (Exception $ex) {
$fullpath = $image->getFullPath();
}
$info = getImageSize($fullpath);
$response->setHeader('content-type', $info['mime']);
$response->setHeader('content-length', filesize($fullpath));
echo file_get_contents($fullpath);
}
开发者ID:kalroot,项目名称:phpweb20demo,代码行数:25,代码来源:UtilityController.php
示例2: gerar_tumbs_real
function gerar_tumbs_real($t_x, $t_y, $qualidade, $c_original, $c_final)
{
$thumbnail = imagecreatetruecolor($t_x, $t_y);
$original = $c_original;
$igInfo = getImageSize($c_original);
switch ($igInfo['mime']) {
case 'image/gif':
if (imagetypes() & IMG_GIF) {
$originalimage = imageCreateFromGIF($original);
} else {
$ermsg = MSG_GIF_NOT_COMPATIBLE . '<br />';
}
break;
case 'image/jpeg':
if (imagetypes() & IMG_JPG) {
$originalimage = imageCreateFromJPEG($original);
} else {
$ermsg = MSG_JPG_NOT_COMPATIBLE . '<br />';
}
break;
case 'image/png':
if (imagetypes() & IMG_PNG) {
$originalimage = imageCreateFromPNG($original);
} else {
$ermsg = MSG_PNG_NOT_COMPATIBLE . '<br />';
}
break;
case 'image/wbmp':
if (imagetypes() & IMG_WBMP) {
$originalimage = imageCreateFromWBMP($original);
} else {
$ermsg = MSG_WBMP_NOT_COMPATIBLE . '<br />';
}
break;
default:
$ermsg = $igInfo['mime'] . MSG_FORMAT_NOT_COMPATIBLE . '<br />';
break;
}
$nLargura = $igInfo[0];
$nAltura = $igInfo[1];
if ($nLargura > $t_x and $nAltura > $t_y) {
if ($t_x <= $t_y) {
$nLargura = (int) ($igInfo[0] * $t_y / $igInfo[1]);
$nAltura = $t_y;
} else {
$nLargura = $t_x;
$nAltura = (int) ($igInfo[1] * $t_x / $igInfo[0]);
if ($nAltura < $t_y) {
$nLargura = (int) ($igInfo[0] * $t_y / $igInfo[1]);
$nAltura = $t_y;
}
}
}
$x_pos = $t_x / 2 - $nLargura / 2;
$y_pos = $t_y / 2 - $nAltura / 2;
imagecopyresampled($thumbnail, $originalimage, $x_pos, $y_pos, 0, 0, $nLargura, $nAltura, $igInfo[0], $igInfo[1]);
imagejpeg($thumbnail, $c_final, $qualidade);
imagedestroy($thumbnail);
return 'ok';
}
开发者ID:amorimlima,项目名称:Hospital,代码行数:60,代码来源:Thumbs.php
示例3: imageAction
/**
* Action - image
* display images in the predetermined size or in the natural size
*
* Access to the action is possible in the following paths:
* - /utility/image
*
* @return void
*/
public function imageAction()
{
$request = $this->getRequest();
$response = $this->getResponse();
$username = $request->getQuery('username');
$id = (int) $request->getQuery('id');
$w = (int) $request->getQuery('w');
$h = (int) $request->getQuery('h');
$hash = $request->getQuery('hash');
$realHash = Default_Model_DbTable_BlogPostImage::GetImageHash($id, $w, $h);
// disable autorendering since we're outputting an image
$this->_helper->viewRenderer->setNoRender();
$image = new Default_Model_DbTable_BlogPostImage($this->db);
if ($hash != $realHash || !$image->load($id)) {
// image not found
$response->setHttpResponseCode(404);
return;
}
try {
$fullpath = $image->createThumbnail($w, $h, $username);
} catch (Exception $ex) {
$fullpath = $image->getFullPath($username);
}
$info = getImageSize($fullpath);
$response->setHeader('content-type', $info['mime']);
$response->setHeader('content-length', filesize($fullpath));
echo file_get_contents($fullpath);
}
开发者ID:bsa-git,项目名称:zf-myblog,代码行数:37,代码来源:UtilityController.php
示例4: load
function load()
{
if ($this->loaded) {
return true;
}
//$size = $this->get_size();
//if (!$size) throw new exception("Failed loading image");
list($this->w, $this->h, $this->type) = getImageSize($this->src);
switch ($this->type) {
case 1:
$this->img = imageCreateFromGif($this->src);
break;
case 2:
$this->img = imageCreateFromJpeg($this->src);
break;
case 3:
$this->img = imageCreateFromPng($this->src);
break;
default:
throw new exception("Unsuported image type");
break;
}
$this->loaded = true;
return true;
}
开发者ID:laiello,项目名称:phpbf,代码行数:25,代码来源:image.php
示例5: initFromPath
/**
* Initialize a layer from a given image path
*
* From an upload form, you can give the "tmp_name" path
*
* @param string $path
*
* @return ImageWorkshopLayer
*/
public static function initFromPath($path)
{
if (file_exists($path) && !is_dir($path)) {
if (!is_readable($path)) {
throw new ImageWorkshopException('Can\'t open the file at "' . $path . '" : file is not writable, did you check permissions (755 / 777) ?', static::ERROR_NOT_WRITABLE_FILE);
}
$imageSizeInfos = @getImageSize($path);
$mimeContentType = explode('/', $imageSizeInfos['mime']);
if (!$mimeContentType || !array_key_exists(1, $mimeContentType)) {
throw new ImageWorkshopException('Not an image file (jpeg/png/gif) at "' . $path . '"', static::ERROR_NOT_AN_IMAGE_FILE);
}
$mimeContentType = $mimeContentType[1];
switch ($mimeContentType) {
case 'jpeg':
$image = imageCreateFromJPEG($path);
break;
case 'gif':
$image = imageCreateFromGIF($path);
break;
case 'png':
$image = imageCreateFromPNG($path);
break;
default:
throw new ImageWorkshopException('Not an image file (jpeg/png/gif) at "' . $path . '"', static::ERROR_NOT_AN_IMAGE_FILE);
break;
}
return new ImageWorkshopLayer($image);
}
throw new ImageWorkshopException('No such file found at "' . $path . '"', static::ERROR_IMAGE_NOT_FOUND);
}
开发者ID:gdragffy,项目名称:ImageWorkshop,代码行数:39,代码来源:ImageWorkshop.php
示例6: __construct
public function __construct($path)
{
list($this->width, $this->height, $this->type) = @getImageSize($path);
if ($this->type == IMAGETYPE_JPEG) {
$this->image = imageCreateFromJPEG($path);
$this->extension = 'jpg';
if (function_exists('exif_read_data')) {
$this->exif = exif_read_data($path);
}
$this->rotateToExifOrientation();
} else {
if ($this->type == IMAGETYPE_PNG) {
$this->image = imageCreateFromPNG($path);
$this->extension = 'png';
} else {
if ($this->type == IMAGETYPE_GIF) {
$this->image = imageCreateFromGIF($path);
$this->extension = 'gif';
}
}
}
if ($this->image) {
$this->valid = true;
}
}
开发者ID:Norvares,项目名称:nemex,代码行数:25,代码来源:image.php
示例7: getFileResource
/**
* Returns content of a file. If it's an image the content of the file is not returned but rather an image tag is.
* This method is taken from tslib_content
* TODO: cache result
*
* @param string The filename, being a TypoScript resource data type or a FAL-Reference (file:123)
* @param string Additional parameters (attributes). Default is empty alt and title tags.
* @return string If jpg,gif,jpeg,png: returns image_tag with picture in. If html,txt: returns content string
* @see FILE()
*/
public static function getFileResource($fName, $options = array())
{
if (!(is_object($GLOBALS['TSFE']) && is_object($GLOBALS['TSFE']->tmpl))) {
tx_rnbase::load('tx_rnbase_util_Misc');
tx_rnbase_util_Misc::prepareTSFE(array('force' => TRUE));
}
if (self::isFALReference($fName)) {
/** @var FileRepository $fileRepository */
$fileRepository = TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
$fileObject = $fileRepository->findByUid(intval(substr($fName, 5)));
$incFile = is_object($fileObject) ? $fileObject->getForLocalProcessing(FALSE) : FALSE;
} else {
$incFile = self::getFileName($fName);
}
if ($incFile) {
// Im BE muss ein absoluter Pfad verwendet werden
$fullPath = TYPO3_MODE == 'BE' ? PATH_site . $incFile : $incFile;
$utility = tx_rnbase_util_Typo3Classes::getGeneralUtilityClass();
$fileinfo = $utility::split_fileref($incFile);
if ($utility::inList('jpg,gif,jpeg,png', $fileinfo['fileext'])) {
$imgFile = $incFile;
$imgInfo = @getImageSize($imgFile);
$addParams = isset($options['addparams']) ? $options['addparams'] : 'alt="" title=""';
$ret = '<img src="' . $GLOBALS['TSFE']->absRefPrefix . $imgFile . '" width="' . $imgInfo[0] . '" height="' . $imgInfo[1] . '"' . self::getBorderAttr(' border="0"') . ' ' . $addParams . ' />';
} elseif (file_exists($fullPath) && filesize($fullPath) < 1024 * 1024) {
$ret = @file_get_contents($fullPath);
$subpart = isset($options['subpart']) ? $options['subpart'] : '';
if ($subpart) {
tx_rnbase::load('tx_rnbase_util_Templates');
$ret = tx_rnbase_util_Templates::getSubpart($ret, $subpart);
}
}
}
return $ret;
}
开发者ID:RocKordier,项目名称:rn_base,代码行数:45,代码来源:class.tx_rnbase_util_Files.php
示例8: _getImageResource
private function _getImageResource($image_file, $save = FALSE)
{
$image_info = getImageSize($image_file);
if ($save) {
$this->_image_mime = $image_info['mime'];
}
switch ($image_info['mime']) {
case 'image/gif':
if ($save) {
$this->_image_type = 'gif';
}
$img_rs = imageCreateFromGIF($image_file);
break;
case 'image/jpeg':
if ($save) {
$this->_image_type = 'jpeg';
}
$img_rs = imageCreateFromJPEG($image_file);
break;
case 'image/png':
if ($save) {
$this->_image_type = 'png';
}
$img_rs = imageCreateFromPNG($image_file);
imageAlphaBlending($img_rs, TRUE);
imageSaveAlpha($img_rs, TRUE);
break;
}
return $img_rs;
}
开发者ID:EmranAhmed,项目名称:envato-watermark-image-replacement,代码行数:30,代码来源:dummy_Image_Replacement.php
示例9: create
/**
* Creates a new smiley.
*
* @return Smiley new smiley
*/
public static function create($filename, $destination, $field, $title = null, $code = null, $showOrder = 0, $smileyCategoryID = 0)
{
if (!file_exists($filename)) {
throw new UserInputException($field, 'notFound');
}
if (!getImageSize($filename)) {
throw new UserInputException($field, 'noValidImage');
}
// copy
if ($filename != $destination && !copy($filename, $destination)) {
throw new UserInputException($field, 'copyFailed');
}
// set permissions
@chmod($destination, 0666);
// generate title & code by filename
$name = preg_replace('/\\.[^\\.]+$/', '', basename($destination));
if ($title === null) {
$title = $name;
}
if ($code === null) {
$code = ':' . $name . ':';
}
// save data
$smileyID = self::insert(str_replace(WCF_DIR, '', $destination), $code, array('smileyTitle' => $title, 'showOrder' => $showOrder, 'smileyCategoryID' => $smileyCategoryID));
// get editor object
$smiley = new SmileyEditor($smileyID);
// save position
$smiley->addPosition($smileyCategoryID, $showOrder);
// save data
return $smiley;
}
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:36,代码来源:SmileyEditor.class.php
示例10: get_any_type
protected function get_any_type($srcpath)
{
try {
$this->check_file($srcpath);
$srcSize = getImageSize($srcpath);
switch ($srcSize[2]) {
case 1:
$img = imageCreateFromGif($srcpath);
break;
case 2:
$img = imageCreateFromJpeg($srcpath);
break;
case 3:
$img = imageCreateFromPng($srcpath);
break;
default:
throw new Imgdexception('not possible to get any type - srcpath:' . $srcpath);
break;
}
$image['width'] = $srcSize[0];
$image['height'] = $srcSize[1];
$image['img'] = $img;
return $image;
} catch (Imgdexception $e) {
$e->print_debug(__FILE__, __LINE__);
return false;
}
}
开发者ID:debugteam,项目名称:baselib,代码行数:28,代码来源:Imagegd.php
示例11: check_image_size
/** check if image has correct width and height (0 for unlimited values)
*
* @example $rule_image_3 = new NetefxValidatorRuleFUNCTION("Image", "image width at least 10, image height at most 500", 'error',
* array('NetefxValidatorLibraryFile', 'check_image_size',
* array('field' => 'Image', 'minWidth' => 10, 'maxWidth' => 0, 'minHeight' => 0, 'maxHeight' => 500)));
*/
static function check_image_size($data, $args)
{
$field = $args["field"];
$arr_file = $data[$field];
if ($arr_file["tmp_name"]) {
$image_size = getImageSize($arr_file["tmp_name"]);
if ($image_size) {
$width = $image_size[0];
$height = $image_size[1];
$minWidth = $args["minWidth"];
$minHeight = $args["minHeight"];
$maxWidth = $args["maxWidth"];
$maxHeight = $args["maxHeight"];
if ($minWidth and $width < $minWidth) {
return false;
}
if ($minHeight and $height < $minHeight) {
return false;
}
if ($maxWidth and $width > $maxWidth) {
return false;
}
if ($maxHeight and $height > $maxHeight) {
return false;
}
}
}
return true;
}
开发者ID:helpfulrobot,项目名称:lxberlin-netefx-validator,代码行数:35,代码来源:NetefxValidatorLibraryFile.php
示例12: image_createThumb
function image_createThumb($src, $dest, $maxWidth, $maxHeight, $quality = 75)
{
if (file_exists($src) && isset($dest)) {
// path info
$destInfo = pathInfo($dest);
// image src size
$srcSize = getImageSize($src);
// image dest size $destSize[0] = width, $destSize[1] = height
$srcRatio = $srcSize[0] / $srcSize[1];
// width/height ratio
$destRatio = $maxWidth / $maxHeight;
if ($destRatio > $srcRatio) {
$destSize[1] = $maxHeight;
$destSize[0] = $maxHeight * $srcRatio;
} else {
$destSize[0] = $maxWidth;
$destSize[1] = $maxWidth / $srcRatio;
}
// path rectification
if ($destInfo['extension'] == "gif") {
$dest = substr_replace($dest, 'jpg', -3);
}
// true color image, with anti-aliasing
$destImage = imageCreateTrueColor($destSize[0], $destSize[1]);
// imageAntiAlias($destImage,true);
// src image
switch ($srcSize[2]) {
case 1:
//GIF
$srcImage = imageCreateFromGif($src);
break;
case 2:
//JPEG
$srcImage = imageCreateFromJpeg($src);
break;
case 3:
//PNG
$srcImage = imageCreateFromPng($src);
break;
default:
return false;
break;
}
// resampling
imageCopyResampled($destImage, $srcImage, 0, 0, 0, 0, $destSize[0], $destSize[1], $srcSize[0], $srcSize[1]);
// generating image
switch ($srcSize[2]) {
case 1:
case 2:
imageJpeg($destImage, $dest, $quality);
break;
case 3:
imagePng($destImage, $dest);
break;
}
return true;
} else {
return 'No such File';
}
}
开发者ID:rolfvandervleuten,项目名称:DeepskyLog,代码行数:60,代码来源:resize.php
示例13: create_thumb
function create_thumb($src_file, $thumb_file, $t_width, $t_height)
{
if (!file_exists($src_file)) {
return false;
}
$src_info = getImageSize($src_file);
//如果来源图像小于或等于缩略图则拷贝源图像作为缩略图
if ($src_info[0] <= $t_width && $src_info[1] <= $t_height) {
if (!copy($src_file, $thumb_file)) {
return false;
}
return true;
}
//按比例计算缩略图大小
if ($src_info[0] - $t_width > $src_info[1] - $t_height) {
$t_height = $t_width / $src_info[0] * $src_info[1];
} else {
$t_width = $t_height / $src_info[1] * $src_info[0];
}
//取得文件扩展名
$fileext = get_ext($src_file);
switch ($fileext) {
case 'jpg':
$src_img = ImageCreateFromJPEG($src_file);
break;
case 'png':
$src_img = ImageCreateFromPNG($src_file);
break;
case 'gif':
$src_img = ImageCreateFromGIF($src_file);
break;
}
//创建一个真彩色的缩略图像
$thumb_img = @ImageCreateTrueColor($t_width, $t_height);
//ImageCopyResampled函数拷贝的图像平滑度较好,优先考虑
if (function_exists('imagecopyresampled')) {
@ImageCopyResampled($thumb_img, $src_img, 0, 0, 0, 0, $t_width, $t_height, $src_info[0], $src_info[1]);
} else {
@ImageCopyResized($thumb_img, $src_img, 0, 0, 0, 0, $t_width, $t_height, $src_info[0], $src_info[1]);
}
//生成缩略图
switch ($fileext) {
case 'jpg':
ImageJPEG($thumb_img, $thumb_file);
break;
case 'gif':
ImageGIF($thumb_img, $thumb_file);
break;
case 'png':
ImagePNG($thumb_img, $thumb_file);
break;
}
//销毁临时图像
@ImageDestroy($src_img);
@ImageDestroy($thumb_img);
return true;
}
开发者ID:omusico,项目名称:Social,代码行数:57,代码来源:cut_image.php
示例14: get_image_size
static function get_image_size($filename)
{
if (isset(self::$gisz[$filename])) {
return self::$gisz[$filename];
}
$sz = @getImageSize($filename);
self::$gisz[$filename] = $sz;
return $sz;
}
开发者ID:techart,项目名称:tao,代码行数:9,代码来源:Images.php
示例15: create_thumb
function create_thumb($path, $thumb_path, $width = THUMB_WIDTH, $height = THUMB_HEIGHT)
{
$image_info = getImageSize($path);
// see EXIF for faster way
switch ($image_info['mime']) {
case 'image/gif':
if (imagetypes() & IMG_GIF) {
// not the same as IMAGETYPE
$o_im = @imageCreateFromGIF($path);
} else {
throw new Exception('GIF images are not supported');
}
break;
case 'image/jpeg':
if (imagetypes() & IMG_JPG) {
$o_im = @imageCreateFromJPEG($path);
} else {
throw new Exception('JPEG images are not supported');
}
break;
case 'image/png':
if (imagetypes() & IMG_PNG) {
$o_im = @imageCreateFromPNG($path);
} else {
throw new Exception('PNG images are not supported');
}
break;
case 'image/wbmp':
if (imagetypes() & IMG_WBMP) {
$o_im = @imageCreateFromWBMP($path);
} else {
throw new Exception('WBMP images are not supported');
}
break;
default:
throw new Exception($image_info['mime'] . ' images are not supported');
break;
}
list($o_wd, $o_ht, $html_dimension_string) = $image_info;
$ratio = $o_wd / $o_ht;
$t_ht = $width;
$t_wd = $height;
if (1 > $ratio) {
$t_wd = round($o_wd * $t_wd / $o_ht);
} else {
$t_ht = round($o_ht * $t_ht / $o_wd);
}
$t_wd = $t_wd < 1 ? 1 : $t_wd;
$t_ht = $t_ht < 1 ? 1 : $t_ht;
$t_im = imageCreateTrueColor($t_wd, $t_ht);
imageCopyResampled($t_im, $o_im, 0, 0, 0, 0, $t_wd, $t_ht, $o_wd, $o_ht);
imagejpeg($t_im, $thumb_path, 85);
chmod($thumb_path, 0664);
imageDestroy($o_im);
imageDestroy($t_im);
return array($t_wd, $t_ht);
}
开发者ID:sztanpet,项目名称:aoiboard,代码行数:57,代码来源:functions.php
示例16: thumbnail
function thumbnail($image, $width, $height, $extension)
{
$data = getImageSize($image);
$imageInfo["width"] = $data[0];
$imageInfo["height"] = $data[1];
$imageInfo["type"] = $data[2];
switch ($imageInfo["type"]) {
case 1:
$img = imagecreatefromgif($image);
break;
case 2:
$img = imageCreatefromjpeg($image);
break;
case 3:
$img = imageCreatefrompng($image);
break;
default:
return false;
}
$size["width"] = $imageInfo["width"];
$size["height"] = $imageInfo["height"];
if ($width < $imageInfo["width"]) {
$size["width"] = $width;
}
if ($height < $imageInfo["height"]) {
$size["height"] = $height;
}
if ($imageInfo["width"] * $size["width"] > $imageInfo["height"] * $size["height"]) {
$size["height"] = round($imageInfo["height"] * $size["width"] / $imageInfo["width"]);
} else {
$size["width"] = round($imageInfo["width"] * $size["height"] / $imageInfo["height"]);
}
$newImg = imagecreatetruecolor($size["width"], $size["height"]);
$otsc = imagecolortransparent($img);
if ($otsc >= 0 && $otsc <= imagecolorstotal($img)) {
$tran = imagecolorsforindex($img, $otsc);
$newt = imagecolorallocate($newImg, $tran["red"], $tran["green"], $tran["blue"]);
imagefill($newImg, 0, 0, $newt);
imagecolortransparent($newImg, $newt);
}
imagecopyresized($newImg, $img, 0, 0, 0, 0, $size["width"], $size["height"], $imageInfo["width"], $imageInfo["height"]);
imagedestroy($img);
$newName = str_replace('.', $extension . '.', $image);
switch ($imageInfo["type"]) {
case 1:
$result = imageGif($newImg, $newName);
break;
case 2:
$result = imageJPEG($newImg, $newName);
break;
case 3:
$result = imagepng($newImg, $newName);
break;
}
imagedestroy($newImg);
}
开发者ID:leamiko,项目名称:interest,代码行数:56,代码来源:common.php
示例17: __construct
public function __construct($file)
{
$this->setFileName($file['name']);
$this->setType($file['type']);
$this->setSize($file['size']);
$this->setTempName($file['tmp_name']);
$dimensions = getImageSize($this->getTempName());
$this->setWidth($dimensions[0]);
$this->setHeight($dimensions[1]);
}
开发者ID:nclundsten,项目名称:ImageUploader,代码行数:10,代码来源:Image.php
示例18: createFromFile
/**
* {@inheritDoc}
*/
public static function createFromFile($filename)
{
$data = @getImageSize($filename);
if ($data && is_array($data)) {
$function = 'imagecreatefrom' . image_type_to_extension($data[2], false);
if (function_exists($function)) {
return new static($function($filename), $data[2]);
}
}
throw new ImageException("The image file '{$filename}' cannot be loaded");
}
开发者ID:marcha,项目名称:imagecow,代码行数:14,代码来源:Gd.php
示例19: downLoadPic
function downLoadPic($url, $dir = "downloads/")
{
$info = @getImageSize($url);
if ($info === false) {
return;
}
$suffix = image_type_to_extension($info[2], false);
$img = file_get_contents($url);
$filename = uniqid() . '.' . $suffix;
file_put_contents($dir . $filename, $img);
}
开发者ID:jiangshanmeta,项目名称:php,代码行数:11,代码来源:getpic.php
示例20: MakeThumbnail
public function MakeThumbnail($o_file, $fileName, $quality, $width, $height)
{
$image_info = getImageSize($o_file);
switch ($image_info['mime']) {
case 'image/gif':
if (imagetypes() & IMG_GIF) {
// not the same as IMAGETYPE
$o_im = imageCreateFromGIF($o_file);
}
break;
case 'image/jpeg':
if (imagetypes() & IMG_JPG) {
$o_im = imageCreateFromJPEG($o_file);
}
break;
case 'image/png':
if (imagetypes() & IMG_PNG) {
$o_im = imageCreateFromPNG($o_file);
}
break;
case 'image/wbmp':
if (imagetypes() & IMG_WBMP) {
$o_im = imageCreateFromWBMP($o_file);
}
break;
default:
break;
}
$o_wd = imagesx($o_im);
$o_ht = imagesy($o_im);
// thumbnail width = target * original width / original height
if ($o_ht > $o_wd) {
$t_wd = round($o_wd * $height / $o_ht);
$t_ht = $height;
}
if ($o_ht < $o_wd) {
$t_ht = round($o_ht * $width / $o_wd);
$t_wd = $width;
}
if ($t_ht > $height) {
$t_wd = round($o_wd * $height / $o_ht);
$t_ht = $height;
}
$t_im = imageCreateTrueColor($t_wd, $t_ht);
imageCopyResampled($t_im, $o_im, 0, 0, 0, 0, $t_wd, $t_ht, $o_wd, $o_ht);
imageJPEG($t_im, $fileName, 100);
imageDestroy($o_im);
imageDestroy($t_im);
return true;
}
开发者ID:alexchitoraga,项目名称:tunet,代码行数:50,代码来源:TFiles.class.php
注:本文中的getImageSize函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论