本文整理汇总了PHP中imagecreatefromwbmp函数的典型用法代码示例。如果您正苦于以下问题:PHP imagecreatefromwbmp函数的具体用法?PHP imagecreatefromwbmp怎么用?PHP imagecreatefromwbmp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagecreatefromwbmp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* Loads the image from given file.
*
* @param string $imagePath
*
* @return null
*/
public function load($imagePath)
{
if (!file_exists($imagePath)) {
throw new Exception('WiseChatImageEditor: File does not exist');
}
$imageData = getimagesize($imagePath);
if ($imageData === false) {
throw new Exception('WiseChatImageEditor: The file is not an image');
}
switch ($imageData[2]) {
case IMAGETYPE_GIF:
$this->image = imagecreatefromgif($imagePath);
break;
case IMAGETYPE_JPEG:
$this->image = imagecreatefromjpeg($imagePath);
break;
case IMAGETYPE_PNG:
$this->image = imagecreatefrompng($imagePath);
break;
case IMAGETYPE_WBMP:
$this->image = imagecreatefromwbmp($imagePath);
break;
default:
throw new Exception('WiseChatImageEditor: Image format is not supported');
}
$this->imageData = $imageData;
$this->imagePath = $imagePath;
}
示例2: __construct
public function __construct($path)
{
if (!file_exists($path)) {
throw new Exception("Данного файла нет");
}
$this->type = $this->getType($path);
switch ($this->type) {
case IMAGETYPE_JPEG:
$img = imagecreatefromjpeg($path);
break;
case IMAGETYPE_PNG:
$img = imagecreatefrompng($path);
break;
case IMAGETYPE_PNG:
$img = imagecreatefrompng($path);
break;
case IMAGETYPE_BMP:
$img = imagecreatefromwbmp($path);
break;
default:
$img = false;
}
$this->img = $img;
if (!$this->img) {
throw new Exception('Не удалость создать дескриптор изображения');
}
$this->width = imagesx($this->img);
$this->height = imagesy($this->img);
}
示例3: init
static function init($file)
{
ini_set("memory_limit", "60M");
if (is_file($file)) {
$info = getimagesize($file);
$img = NULL;
switch ($info['mime']) {
case 'image/jpeg':
$img = imagecreatefromjpeg($file);
break;
case 'image/gif':
$img = imagecreatefromgif($file);
break;
case 'image/png':
$img = imagecreatefrompng($file);
break;
case 'image/bmp':
$img = imagecreatefromwbmp($file);
break;
default:
return false;
break;
}
return $img;
} else {
return false;
}
}
示例4: setImage
public function setImage($resource, $versionName)
{
// get image info, validate it's an image
if (!(list($width, $height, $type) = getimagesize($resource))) {
throw new Exception("Must be an image");
}
// get file info
$info = pathinfo($resource);
// create image from resource
switch ($type) {
case IMAGETYPE_JPEG:
$img = imagecreatefromjpeg($resource);
break;
case IMAGETYPE_PNG:
$img = imagecreatefrompng($resource);
break;
case IMAGETYPE_GIF:
$img = imagecreatefromgif($resource);
break;
case IMAGETYPE_BMP:
$img = imagecreatefromwbmp($resource);
break;
default:
throw new Exception("Supplied image must be bmp, gif, jpg or png");
}
// store image & data
$this->_resource = $img;
$this->_width = $width;
$this->_height = $height;
$this->_filename = $info['dirname'] . '/' . $info['filename'] . (!empty($versionName) ? '_' . $versionName : '');
// NOTE: without extension!
$this->_type = $type;
}
示例5: _load_image
private function _load_image($path)
{
list($w, $h, $type) = getimagesize($path);
switch ($type) {
case IMAGETYPE_GIF:
$this->_format = 'gif';
return imagecreatefromgif($path);
case IMAGETYPE_JPEG:
$this->_format = 'jpg';
return imagecreatefromjpeg($path);
case IMAGETYPE_PNG:
$this->_format = 'png';
return imagecreatefrompng($path);
case IMAGETYPE_SWF:
$this->_format = 'swf';
return imagecreatefromswf($path);
case IMAGETYPE_WBMP:
$this->_format = 'wbmp';
return imagecreatefromwbmp($path);
case IMAGETYPE_XBM:
$this->_format = 'xbm';
return imagecreatefromxbm($path);
default:
return imagecreatefromstring(file_get_contents($path));
}
return false;
}
示例6: createImage
/**
* Creation of the original image object.
*
* @return object of the image created.
*/
function createImage()
{
//est� conferindo o arquivo pela exten��o contando que foi conferido o tipo de arquivo ao recebe-lo
$extensao = DataHandler::returnExtensionOfFile($this->image);
// echo Debug::li(filetype($this->image));
// exit();
switch (strtolower($extensao)) {
case 'jpg':
case 'jpeg':
return imagecreatefromjpeg($this->image);
break;
case 'gif':
return imagecreatefromgif($this->image);
break;
case 'png':
return imagecreatefrompng($this->image);
break;
case 'bmp':
return imagecreatefromwbmp($this->image);
break;
default:
return imagecreatefromjpeg($this->image);
break;
}
}
示例7: getImageFromUrl
public static function getImageFromUrl($image_url)
{
try {
$mime = image_type_to_mime_type(exif_imagetype($image_url));
} catch (Exception $e) {
throw new MimeTypeException($e->getMessage());
}
//Get image based on mime and set to $im
switch ($mime) {
case 'image/jpeg':
$im = imagecreatefromjpeg($image_url);
break;
case 'image/gif':
$im = imagecreatefromgif($image_url);
break;
case 'image/png':
$im = imagecreatefrompng($image_url);
break;
case 'image/wbmp':
$im = imagecreatefromwbmp($image_url);
break;
default:
throw new MimeTypeException("An image of '{$mime}' mime type is not supported.");
break;
}
return $im;
}
示例8: imageResize
function imageResize($file, $name, $h, $w)
{
// Get File Extension
$type = substr($file, -3);
switch ($type) {
case $type == 'jpg':
$canvas = imagecreatefromjpeg($file);
break;
case $type == 'png':
$canvas = imagecreatefrompng($file);
break;
case $type == 'bmp':
$canvas = imagecreatefromwbmp($file);
break;
case $type == 'gif':
$canvas = imagecreatefromgif($file);
break;
}
// getimagesize(); => returns arr[width,height]
$size = getimagesize($file);
$fileWidth = $size[0];
$fileHeight = $size[1];
// imagecreatetruecolor(width, height)
$content = imagecreatetruecolor($w, $h);
// imagecopyresampled(dst_image, src_image, dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h)
imagecopyresampled($content, $canvas, 0, 0, 0, 0, $w, $h, $fileWidth, $fileHeight);
// imagepng($content, src file, quality 0-9);
imagepng($content, $name, 9);
// Frees up the resources by remove the canvas from the RAM
imagedestroy($canvas);
}
示例9: render
public function render($source)
{
$this->s_image = $source;
list($this->image['width'], $this->image['height']) = getimagesize($source);
$this->image['extension'] = strtolower(preg_replace('/^.*\\.([^.]+)$/D', '$1', $this->s_image));
if (!in_array($this->image['extension'], $this->valid_ext)) {
echo 'Invalid format!';
$this->halt = true;
}
switch ($this->image['extension']) {
case 'png':
$this->image['render'] = imagecreatefrompng($this->s_image);
imagealphablending($this->image['render'], false);
imagesavealpha($this->image['render'], true);
break;
case 'jpg':
$this->image['render'] = imagecreatefromjpeg($this->s_image);
break;
case 'jpeg':
$this->image['render'] = imagecreatefromjpeg($this->s_image);
break;
case 'gif':
$this->image['render'] = imagecreatefromgif($this->s_image);
break;
case 'bmp':
$this->image['render'] = imagecreatefromwbmp($this->s_image);
break;
case 'wbmp':
$this->image['render'] = imagecreatefromwbmp($this->s_image);
break;
}
}
示例10: getImage
protected function getImage($image_url)
{
$this->url = $image_url;
$mime = image_type_to_mime_type(exif_imagetype($image_url));
$im;
//Get image based on mime and set to $im
switch ($mime) {
case 'image/jpeg':
$im = imagecreatefromjpeg($image_url);
break;
case 'image/gif':
$im = imagecreatefromgif($image_url);
break;
case 'image/png':
$im = imagecreatefrompng($image_url);
break;
case 'image/wbmp':
$im = imagecreatefromwbmp($image_url);
break;
default:
return NULL;
break;
}
$this->image = $im;
return $this;
}
示例11: create_pic
function create_pic($upfile, $new_path, $width)
{
$quality = 100;
$image_path = $upfile;
$image_info = getimagesize($image_path);
$exname = '';
//1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF
switch ($image_info[2]) {
case 1:
@($image = imagecreatefromgif($image_path));
$exname = 'gif';
break;
case 2:
@($image = imagecreatefromjpeg($image_path));
$exname = 'jpg';
break;
case 3:
@($image = imagecreatefrompng($image_path));
$exname = 'png';
break;
case 6:
@($image = imagecreatefromwbmp($image_path));
$exname = 'wbmp';
break;
}
$T_width = $image_info[0];
$T_height = $image_info[1];
if (!empty($image)) {
$image_x = imagesx($image);
$image_y = imagesy($image);
} else {
return FALSE;
}
@chmod($new_path, 0777);
if ($image_x > $width) {
$x = $width;
$y = intval($x * $image_y / $image_x);
} else {
@copy($image_path, $new_path . '.' . $exname);
return $exname;
}
$newimage = imagecreatetruecolor($x, $y);
imagecopyresampled($newimage, $image, 0, 0, 0, 0, $x, $y, $image_x, $image_y);
switch ($image_info[2]) {
case 1:
imagegif($newimage, $new_path . '.gif', $quality);
break;
case 2:
imagejpeg($newimage, $new_path . '.jpg', $quality);
break;
case 3:
imagepng($newimage, $new_path . '.png', $quality);
break;
case 6:
imagewbmp($newimage, $new_path . '.wbmp', $quality);
break;
}
imagedestroy($newimage);
return $exname;
}
示例12: build_image
/** Returns an array. Element 0 - GD resource. Element 1 - width. Element 2 - height.
* Returns FALSE on failure. The only one parameter $image can be an instance of this class,
* a GD resource, an array(width, height) or path to image file.
* @param mixed $image
* @return array */
protected function build_image($image)
{
if ($image instanceof gd) {
$width = $image->get_width();
$height = $image->get_height();
$image = $image->get_image();
} elseif (is_resource($image) && get_resource_type($image) == "gd") {
$width = @imagesx($image);
$height = @imagesy($image);
} elseif (is_array($image)) {
list($key, $width) = each($image);
list($key, $height) = each($image);
$image = imagecreatetruecolor($width, $height);
} elseif (false !== (list($width, $height, $type) = @getimagesize($image))) {
$image = $type == IMAGETYPE_GIF ? @imagecreatefromgif($image) : ($type == IMAGETYPE_WBMP ? @imagecreatefromwbmp($image) : ($type == IMAGETYPE_JPEG ? @imagecreatefromjpeg($image) : ($type == IMAGETYPE_JPEG2000 ? @imagecreatefromjpeg($image) : ($type == IMAGETYPE_PNG ? imagecreatefrompng($image) : ($type == IMAGETYPE_XBM ? @imagecreatefromxbm($image) : false)))));
if ($type == IMAGETYPE_PNG) {
imagealphablending($image, false);
}
}
$return = is_resource($image) && get_resource_type($image) == "gd" && isset($width) && isset($height) && preg_match('/^[1-9][0-9]*$/', $width) !== false && preg_match('/^[1-9][0-9]*$/', $height) !== false ? array($image, $width, $height) : false;
if ($return !== false && isset($type)) {
$this->type = $type;
}
return $return;
}
示例13: load
function load($filename)
{
$image_info = getimagesize($filename);
$this->image_type = $image_info[2];
$this->filename = $filename;
switch ($this->image_type) {
case IMAGETYPE_JPEG:
$this->image = @imagecreatefromjpeg($filename);
return true;
case IMAGETYPE_GIF:
$this->image = @imagecreatefromgif($filename);
return true;
case IMAGETYPE_PNG:
$this->image = @imagecreatefrompng($filename);
return true;
case IMAGETYPE_WBMP:
$this->image = @imagecreatefromwbmp($filename);
return true;
default:
$this->image = false;
}
if ($this->image) {
return true;
} else {
return false;
}
}
示例14: setImage
public function setImage($path)
{
$info = getimagesize($path);
if ($info) {
$this->imageType = $info['mime'];
$this->originalWidth = $info[0];
$this->originalHeight = $info[1];
$this->originalPath = $path;
switch ($this->imageType) {
case 'image/gif':
$this->gd = imagecreatefromgif($path);
break;
case 'image/jpeg':
$this->gd = imagecreatefromjpeg($path);
break;
case 'image/png':
$this->gd = imagecreatefrompng($path);
break;
case 'image/wbmp':
$this->gd = imagecreatefromwbmp($path);
break;
}
}
return $info;
}
示例15: prepare
public function prepare()
{
if (!isset($this->img['src'])) {
$this->gifsupport = function_exists('imagegif');
// if mimetype detected and in imagemap -> change format
if (class_exists("finfo") && ($finfo = new finfo(FILEINFO_MIME_TYPE))) {
if ($ftype = @$finfo->file($this->img['filepath'])) {
if (array_key_exists($ftype, $this->image_mimetype_map)) {
$this->img['format'] = $this->image_mimetype_map[$ftype];
}
}
}
// ----- detect image format
if ($this->img['format'] == 'jpg' || $this->img['format'] == 'jpeg') {
$this->img['format'] = 'jpeg';
$this->img['src'] = @imagecreatefromjpeg($this->img['filepath']);
} elseif ($this->img['format'] == 'png') {
$this->img['src'] = @imagecreatefrompng($this->img['filepath']);
imagealphablending($this->img['src'], false);
imagesavealpha($this->img['src'], true);
} elseif ($this->img['format'] == 'gif') {
if ($this->gifsupport) {
$this->img['src'] = @imagecreatefromgif($this->img['filepath']);
}
} elseif ($this->img['format'] == 'wbmp') {
$this->img['src'] = @imagecreatefromwbmp($this->img['filepath']);
}
if (isset($this->img['src'])) {
$this->refreshDimensions();
}
}
}