本文整理汇总了PHP中WideImage::registerCustomMapper方法的典型用法代码示例。如果您正苦于以下问题:PHP WideImage::registerCustomMapper方法的具体用法?PHP WideImage::registerCustomMapper怎么用?PHP WideImage::registerCustomMapper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WideImage
的用法示例。
在下文中一共展示了WideImage::registerCustomMapper方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createTrueColorImage
*/
static function createTrueColorImage($width, $height)
{
return WideImage_TrueColorImage::create($width, $height);
}
/**
* Check whether the given handle is a valid GD resource
*
* @param mixed $handle The variable to check
* @return bool
*/
static function isValidImageHandle($handle)
{
return is_resource($handle) && get_resource_type($handle) == 'gd';
}
/**
* Throws exception if the handle isn't a valid GD resource
*
* @param mixed $handle The variable to check
*/
static function assertValidImageHandle($handle)
{
if (!self::isValidImageHandle($handle)) {
throw new WideImage_InvalidImageHandleException("{$handle} is not a valid image handle.");
}
}
}
WideImage::checkGD();
WideImage::registerCustomMapper('WideImage_Mapper_BMP', 'image/bmp', 'bmp');
WideImage::registerCustomMapper('WideImage_Mapper_TGA', 'image/tga', 'tga');
示例2: testLoadFromFileFallbackToLoadFromString
function testLoadFromFileFallbackToLoadFromString()
{
WideImage_Mapper_FOO::$handle = imagecreate(10, 10);
$filename = IMG_PATH . '/image-actually-foo.foo2';
WideImage::registerCustomMapper('WideImage_Mapper_FOO', 'image/foo', 'foo');
WideImage::registerCustomMapper('WideImage_Mapper_FOO2', 'image/foo2', 'foo2');
$img = WideImage::load($filename);
$this->assertEquals(WideImage_Mapper_FOO2::$calls['load'], array($filename));
$this->assertEquals(WideImage_Mapper_FOO::$calls['loadFromString'], array(file_get_contents($filename)));
imagedestroy(WideImage_Mapper_FOO::$handle);
}