本文整理汇总了PHP中image::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP image::getType方法的具体用法?PHP image::getType怎么用?PHP image::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类image
的用法示例。
在下文中一共展示了image::getType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
*
* @param string $filename
* @param image $sourceImage
* @param rectangle $rectangle
*/
public function __construct($filename, $sourceImage, $rectangle)
{
parent::__construct($filename);
$this->setType($sourceImage->getType());
$this->fromArea($sourceImage, $rectangle);
$this->save();
}
示例2: save
/**
*
* @param image $image
*/
public function save($image)
{
if (is_resource($image->meta)) {
switch ($image->getType()) {
case 1:
imagegif($image->meta, $image->getFilename());
break;
case 2:
imagejpeg($image->meta, $image->getFilename(), self::$_jpegQuality);
break;
case 3:
imagepng($image->meta, $image->getFilename(), self::$_pngCompression, self::$_pngFilters);
break;
default:
break;
}
}
}
示例3: dirname
$dir = dirname(__FILE__);
$fixtures = $dir . '/../fixtures/image';
require $dir . '/../../lib/php/model/image.class.php';
$baseImage = $fixtures . '/FordMustang.jpg';
$waterMark = $fixtures . '/black-opacity.png';
$image = new image($baseImage);
$images = array();
logSection($image->isActive(), 'is valid image', 'info');
if (!$image->isActive()) {
logSection('exit', 'image is invalid, operation can not be finished', 'error');
}
$width = $image->getData('width');
$height = $image->getData('height');
logSection($width . 'x' . $height, 'test getData method', 'info');
logSection('jpeg' == $image->getType(), 'test getType method', 'info');
$image->resize(500, 500, 'height');
$image->save($fixtures . '/FordMustang-500h.jpg');
$images[] = $fixtures . '/FordMustang-500h.jpg';
logSection(file_exists($fixtures . '/FordMustang-500h.jpg'), '->resize(500, 500, height)->save(FordMustang-500h.jpg)');
logSection($image->getData('height') == 500, 'height == 500');
$image->resize(500, 500, 'width');
$image->save($fixtures . '/FordMustang-500w.jpg');
$images[] = $fixtures . '/FordMustang-500w.jpg';
logSection(file_exists($fixtures . '/FordMustang-500w.jpg'), '->resize(500, 500, width)->save(FordMustang-500w.jpg)');
logSection($image->getData('width') == 500, 'width == 500');
$image->resize(500, 500, 'auto');
$image->save($fixtures . '/FordMustang-500a.jpg');
$images[] = $fixtures . '/FordMustang-500a.jpg';
logSection(file_exists($fixtures . '/FordMustang-500w.jpg'), '->resize(500, 500, auto)->save(FordMustang-500a.jpg)');
logSection($image->getData('width') == 500, 'width == 500');