本文整理汇总了PHP中imagecreatefrombmp函数的典型用法代码示例。如果您正苦于以下问题:PHP imagecreatefrombmp函数的具体用法?PHP imagecreatefrombmp怎么用?PHP imagecreatefrombmp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagecreatefrombmp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compressImage
function compressImage($ext, $uploadedfile, $path, $actual_image_name, $newwidth)
{
if ($ext == "jpg" || $ext == "jpeg") {
$src = imagecreatefromjpeg($uploadedfile);
} else {
if ($ext == "png") {
$src = imagecreatefrompng($uploadedfile);
} else {
if ($ext == "gif") {
$src = imagecreatefromgif($uploadedfile);
} else {
$src = imagecreatefrombmp($uploadedfile);
}
}
}
list($width, $height) = getimagesize($uploadedfile);
$newheight = $height / $width * $newwidth;
$tmp = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$filename = $path . $newwidth . '_' . $actual_image_name;
//PixelSize_TimeStamp.jpg
imagejpeg($tmp, $filename, 100);
imagedestroy($tmp);
return $filename;
}
示例2: load
function load($img_name, $img_type = '')
{
if (!empty($img_type)) {
$this->_imagetype = $img_type;
} else {
$this->_imagetype = $this->get_type($img_name);
}
switch ($this->_imagetype) {
case 'gif':
if (function_exists('imagecreatefromgif')) {
$this->_img = imagecreatefromgif($img_name);
}
break;
case 'jpg':
case 'jpeg':
$this->_img = imagecreatefromjpeg($img_name);
break;
case 'bmp':
include_once dirname(__FILE__) . '/gdbmp.php';
$this->_img = imagecreatefrombmp($img_name);
break;
case 'png':
$this->_img = imagecreatefrompng($img_name);
break;
default:
$this->_img = imagecreatefromstring($img_name);
break;
}
$this->getxy();
}
示例3: ConvertImage
private function ConvertImage($originalImage, $outputImage, $quality)
{
// jpg, png, gif or bmp?
$exploded = explode('.', $originalImage);
$ext = $exploded[count($exploded) - 1];
if (preg_match('/jpg|jpeg/i', $ext)) {
$imageTmp = imagecreatefromjpeg($originalImage);
} else {
if (preg_match('/png/i', $ext)) {
$imageTmp = imagecreatefrompng($originalImage);
} else {
if (preg_match('/gif/i', $ext)) {
$imageTmp = imagecreatefromgif($originalImage);
} else {
if (preg_match('/bmp/i', $ext)) {
$imageTmp = imagecreatefrombmp($originalImage);
} else {
return 0;
}
}
}
}
// quality is a value from 0 (worst) to 100 (best)
imagejpeg($imageTmp, $outputImage, $quality);
imagedestroy($imageTmp);
return 1;
}
示例4: convertImage
function convertImage($originalImage, $outputImage, $quality = 100)
{
$myfile = fopen($outputImage, "w");
// jpg, png, gif or bmp?
$exploded = explode('.', $originalImage);
$ext = $exploded[count($exploded) - 1];
if (preg_match('/jpg|jpeg/i', $ext)) {
$imageTmp = imagecreatefromjpeg($originalImage);
} else {
if (preg_match('/png/i', $ext)) {
$imageTmp = imagecreatefrompng($originalImage);
} else {
if (preg_match('/gif/i', $ext)) {
$imageTmp = imagecreatefromgif($originalImage);
} else {
if (preg_match('/bmp/i', $ext)) {
$imageTmp = imagecreatefrombmp($originalImage);
} else {
return 0;
}
}
}
}
imagejpeg($imageTmp, $outputImage, $quality);
imagedestroy($imageTmp);
return $outputImage;
}
示例5: load
public function load($path, $realname = null)
{
if (!file_exists($path)) {
return false;
}
if ($realname == null) {
$pinfo = pathinfo($path);
$ext = $pinfo["extension"];
} else {
$pinfo = pathinfo($realname);
$ext = $pinfo["extension"];
}
switch (strtolower($ext)) {
case "jpeg":
case "jpg":
$this->image = imagecreatefromjpeg($path);
break;
case "gif":
$this->image = imagecreatefromgif($path);
break;
case "png":
$this->image = imagecreatefrompng($path);
break;
case "bmp":
$this->image = imagecreatefrombmp($path);
break;
}
if ($this->image == null) {
return false;
}
return true;
}
示例6: imageresize_temp
function imageresize_temp($image_url, $extension, $image_width = "260")
{
switch ($extension) {
case 'jpeg':
$simg = imagecreatefromjpeg($image_url);
break;
case 'jpg':
$simg = imagecreatefromjpeg($image_url);
break;
case 'png':
$simg = imagecreatefrompng($image_url);
break;
case 'bmp':
$simg = imagecreatefrombmp($image_url);
break;
case 'gif':
$simg = imagecreatefromgif($image_url);
break;
default:
return false;
}
$currwidth = imagesx($simg);
$currheight = imagesy($simg);
$zoom = $image_width / $currwidth;
$newwidth = $image_width;
$newheight = $currheight * $zoom;
$dimg = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight);
$filename = '/tmp/' . time() . '.' . $extension;
imagejpeg($dimg, $filename);
imagedestroy($simg);
imagedestroy($dimg);
return $filename;
}
示例7: convertImage
function convertImage($originalImage, $outputImage, $quality)
{
$exploded = explode('.', $originalImage);
$ext = $exploded[count($exploded) - 1];
if (preg_match('/jpg|jpeg/i', $ext)) {
$imageTmp = imagecreatefromjpeg($originalImage);
} else {
if (preg_match('/png/i', $ext)) {
$imageTmp = imagecreatefrompng($originalImage);
} else {
if (preg_match('/gif/i', $ext)) {
$imageTmp = imagecreatefromgif($originalImage);
} else {
if (preg_match('/bmp/i', $ext)) {
$imageTmp = imagecreatefrombmp($originalImage);
} else {
return 0;
}
}
}
}
imagejpeg($imageTmp, $outputImage, $quality);
imagedestroy($imageTmp);
print $outputImage;
}
示例8: open_image
function open_image($file)
{
list($width, $height, $type, $attr) = getimagesize($file);
//echo "Type: ".$type."<br />";
// http://www.php.net/manual/en/function.exif-imagetype.php
/*1 IMAGETYPE_GIF
2 IMAGETYPE_JPEG
3 IMAGETYPE_PNG
4 IMAGETYPE_SWF
5 IMAGETYPE_PSD
6 IMAGETYPE_BMP
7 IMAGETYPE_TIFF_II (intel byte order)
8 IMAGETYPE_TIFF_MM (motorola byte order)
9 IMAGETYPE_JPC
10 IMAGETYPE_JP2
11 IMAGETYPE_JPX
12 IMAGETYPE_JB2
13 IMAGETYPE_SWC
14 IMAGETYPE_IFF
15 IMAGETYPE_WBMP
16 IMAGETYPE_XBM
17 IMAGETYPE_ICO */
if ($type == 2) {
$im = @imagecreatefromjpeg($file);
} elseif ($type == 1) {
$im = @imagecreatefromgif($file);
} elseif ($type == 3) {
$im = @imagecreatefrompng($file);
} elseif ($type == 15) {
$im = @imagecreatefromwbmp($file);
} elseif ($type == 6) {
$im = @imagecreatefrombmp($file);
} elseif ($type == 16) {
$im = @imagecreatefromxbm($file);
} else {
$im = @imagecreatefromstring(file_get_contents($file));
}
/*if ( $type == IMAGETYPE_JPEG ) {
$im = @imagecreatefromjpeg($file);
} elseif ( $type == IMAGETYPE_GIF ) {
$im = @imagecreatefromgif($file);
} elseif ( $type == IMAGETYPE_PNG ) {
$im = @imagecreatefrompng($file);
} elseif ( $type == IMAGETYPE_WBMP ) {
$im = @imagecreatefromwbmp($file);
} elseif ( $type == IMAGETYPE_BMP ) {
$im = @imagecreatefrombmp($file);
} elseif ( $type == IMAGETYPE_XBM ) {
$im = @imagecreatefromxbm($file);
} else {
$im = @imagecreatefromstring(file_get_contents($file));
}*/
if ($im !== false) {
return $im;
} else {
die(throwError("Unable to open_image"));
}
return false;
}
示例9: makeThumb
function makeThumb($path, $size, $mime = FALSE)
{
// Verifica se é uma imagem
// @since rev 1
if ($mime === FALSE) {
$mime = mime_content_type($path);
}
if (strpos($mime, "jpeg") !== FALSE) {
$buffer = imagecreatefromjpeg($path);
} elseif (strpos($mime, "bmp") !== FALSE) {
$buffer = imagecreatefrombmp($path);
} elseif (strpos($mime, "gif") !== FALSE) {
$buffer = imagecreatefromgif($path);
} elseif (strpos($mime, "png") !== FALSE) {
$buffer = imagecreatefrompng($path);
} else {
return FALSE;
}
if ($buffer === FALSE) {
return FALSE;
}
// Busca o tamanho da imagem
// @since rev 1
$x = $origem_x = ImagesX($buffer);
$y = $origem_y = ImagesY($buffer);
// Verifica qual deve ser a proporção
// @since rev 1
if ($x >= $y) {
if ($x > $size) {
$x1 = (int) ($x * ($size / $x));
$y1 = (int) ($y * ($size / $x));
} else {
$x1 = $x;
$y1 = $y;
}
} else {
if ($y > $size) {
$x1 = (int) ($x * ($size / $y));
$y1 = (int) ($y * ($size / $y));
} else {
$x1 = $x;
$y1 = $y;
}
}
// Muda o tamanho da imagem
// @since rev 1
$image = ImageCreateTrueColor($x1, $y1);
if ($image === FALSE) {
return FALSE;
}
ImageCopyResampled($image, $buffer, 0, 0, 0, 0, $x1 + 1, $y1 + 1, $origem_x, $origem_y);
// Libera recursos
// @since rev 1
ImageDestroy($buffer);
// Retorna o resource
// @since rev 1
return $image;
}
示例10: INSERT
/**
* Para insertar un nuevo registro, debo pasar la ruta de
* una imagen válida (puede ser de un archivo local o uno remoto con http://...)
*/
public static function INSERT($image_path)
{
// Compruebo si el archivo es en realidad una imagen:
//$finfo = finfo_open(FILEINFO_MIME_TYPE);
//$mime = finfo_file($finfo, $image_path);
$temp_hash = md5(microtime());
Rack::Write('temp', $temp_hash, $image_path);
$temp_path = Rack::Path('temp', $temp_hash);
$is = getimagesize($temp_path);
$mime = $is['mime'];
switch ($mime) {
case 'image/jpeg':
$gd = @imagecreatefromjpeg($temp_path);
break;
case 'image/png':
$gd = @imagecreatefrompng($temp_path);
break;
case 'image/gif':
$gd = @imagecreatefromgif($temp_path);
break;
case 'image/bmp':
$gd = @imagecreatefrombmp($temp_path);
break;
default:
return null;
}
if (is_resource($gd)) {
$width = imagesx($gd);
$height = imagesy($gd);
$hash = md5_file($temp_path);
$list = Image::SELECT("Hash='" . Database::escape($hash) . "'");
if (count($list)) {
// La imagen ya existe :S
$image = $list[0];
$image->_setCounter($image->getCounter() + 1);
} else {
// Creo un nuevo registro de imagen :)
$image = parent::INSERT();
$image->_setWidth($width);
$image->_setHeight($height);
$image->_setMime($mime);
$image->_setHash($hash);
$image->_setSize(@filesize($temp_path));
$image->_setCounter(1);
// Copiar imagen a la carpeta de imágenes con el id de $image->getId(); (o con el hash)
Rack::Write('img', md5($image->ID()), $temp_path);
}
Rack::Remove('temp', $temp_hash);
return $image;
} else {
// Error al abrir la imagen
Rack::Remove('temp', $temp_hash);
return null;
}
}
示例11: init_img
private function init_img()
{
if ($this->type == 'jpeg') {
$this->tem_file = imagecreatefromjpeg($this->sur_file);
} elseif ($this->type == 'jpg') {
$this->tem_file = imagecreatefromjpeg($this->sur_file);
} elseif ($this->type == 'gif') {
$this->tem_file = imagecreatefromgif($this->sur_file);
} elseif ($this->type == 'png') {
$this->tem_file = imagecreatefrompng($this->sur_file);
} elseif ($this->type == 'bmp') {
$this->tem_file = imagecreatefrombmp($this->sur_file);
}
}
示例12: dupeImage
public function dupeImage()
{
$raw_file = DB::get_item_collection_path($this->img_file);
$file_path = Client::getFile($raw_file . '.bmp');
if (file_get_contents($file_path)) {
header('Content-type: image/png');
$im = imagecreatefrombmp($file_path);
//$purple = imagecolorallocate($im, 255, 0, 255);
//imagecolortransparent($im,$purple);
imagepng($im);
imagedestroy($im);
} else {
echo "File does not exist!";
}
}
示例13: createImage
private function createImage()
{
switch ($this->imagetype) {
case 1:
$image = imagecreatefromgif($this->filename);
break;
case 2:
$image = imagecreatefromjpeg($this->filename);
break;
case 3:
$image = imagecreatefrompng($this->filename);
break;
case 6:
$image = imagecreatefrombmp($this->filename);
break;
}
return $image;
}
示例14: getImage
private function getImage()
{
$this->image_info = getimagesize($this->filename);
$this->image_type = $this->image_info[2];
switch ($this->image_type) {
case IMAGETYPE_JPEG:
$this->image = imagecreatefromjpeg($this->filename);
break;
case IMAGETYPE_GIF:
$this->image = imagecreatefromgif($this->filename);
break;
case IMAGETYPE_PNG:
$this->image = imagecreatefrompng($this->filename);
break;
case IMAGETYPE_BMP:
$this->image = imagecreatefrombmp($this->filename);
break;
}
}
示例15: load_image
function load_image($file)
{
$ext = substr($file, strrpos($file, ".") + 1);
$ext = strtolower($ext);
$src_img = false;
if ($ext == "jpg" || $ext == "jpeg") {
$src_img = imagecreatefromjpeg($file);
}
if ($ext == "png") {
$src_img = imagecreatefrompng($file);
}
if ($ext == "gif") {
$src_img = imagecreatefromgif($file);
}
if ($ext == "bmp") {
$src_img = imagecreatefrombmp($file);
}
return $src_img;
}