本文整理汇总了PHP中imagebmp函数的典型用法代码示例。如果您正苦于以下问题:PHP imagebmp函数的具体用法?PHP imagebmp怎么用?PHP imagebmp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagebmp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: imprimir_ticket
public function imprimir_ticket()
{
// Prueba de impresión de ticket directamente a impresora
// Crea codigo de barras
$barras_txt = '0123456790123';
$this->barcode->barcode_img_tipo = 'png';
$barras = ($barrasImg = $this->barcode->create($barras_txt)) ? true : false;
#Crea jpg
$barrasBmp = $barras ? imagebmp('png', $barrasImg, 'assets\\tmp\\barcode.bmp') : false;
#Convierte jpg->bmp
// Crea código QR
$qr_txt = 'http://www.isolution.mx';
$qr = ($qrImg = $this->codeqr->create($qr_txt)) ? true : false;
$qrBmp = $qr ? imagebmp('png', $qrImg, 'assets\\tmp\\qrcode.bmp') : false;
#Convierte jpg->bmp
// Envía datos
$impData = array('contenido' => 'assets\\tmp\\ticket.txt', 'logo' => 'assets/images/logo.bmp', 'impresora' => 'PDFCreator', 'formato' => true, 'codebar' => $barrasBmp, 'codeqr' => $qrBmp);
// Imprime ticket
if ($this->impresion->enviar_a_impresora($impData)) {
echo "Impresión enviada: " . date('Y-m-d H:i:s');
}
// Elimina imagenes generadas
if ($barrasImg) {
unlink($barrasImg);
}
if ($barrasBmp) {
unlink($barrasBmp);
}
if ($qrImg) {
unlink($qrImg);
}
if ($qrBmp) {
unlink($qrBmp);
}
}
示例2: save
function save($handle, $uri = null)
{
if ($uri == null) {
imagebmp($handle);
} else {
imagebmp($handle, $uri);
}
}
示例3: img_thumb
function img_thumb($target, $newcopy, $w, $h, $ext)
{
list($w_orig, $h_orig) = getimagesize($target);
// get image sizes of the uploaded image
$ratio_orig = $w_orig / $h_orig;
// width ratio
// figure out max height or width
if ($w / $h > $ratio_orig) {
$w = $h * $ratio_orig;
} else {
$h = $w / $ratio_orig;
}
$ext = strtolower($ext);
$img = "";
if ($ext == "gif") {
$img = imagecreatefromgif($target);
} else {
if ($ext == "png") {
$img = imagecreatefrompng($target);
} else {
$img = imagecreatefromjpeg($target);
}
}
$tci = imagecreatetruecolor($w, $h);
if ($ext == "gif" or $ext == "png") {
imagecolortransparent($tci, imagecolorallocatealpha($tci, 0, 0, 0, 127));
imagealphablending($tci, false);
imagesavealpha($tci, true);
}
imagecopyresampled($tci, $img, 0, 0, 0, 0, $w, $h, $w_orig, $h_orig);
// if($src_x<0) {
// $bgd = imagecolorallocate($tci, 255, 255, 255);
// imagefill($tci, 0, 0, $bgd);
// }
if ($ext == "gif") {
imagegif($tci, $newcopy);
} else {
if ($ext == "png") {
imagepng($tci, $newcopy);
} else {
if ($ext == "bmp") {
imagebmp($tci, $newcopy);
} else {
imagejpeg($tci, $newcopy, 84);
}
}
}
}
示例4: helper_watermark
function helper_watermark($name, $ext)
{
($hook = kleeja_run_hook('helper_watermark_func')) ? eval($hook) : null;
//run hook
#is this file really exsits ?
if (!file_exists($name)) {
return;
}
$src_logo = $logo_path = false;
if (file_exists(dirname(__FILE__) . '/../../images/watermark.png')) {
$logo_path = dirname(__FILE__) . '/../../images/watermark.png';
$src_logo = imagecreatefrompng($logo_path);
} elseif (file_exists(dirname(__FILE__) . '/../../images/watermark.gif')) {
$logo_path = dirname(__FILE__) . '/../../images/watermark.gif';
$src_logo = imagecreatefromgif($logo_path);
}
#no watermark pic
if (!$src_logo) {
return;
}
#if there is imagick lib, then we should use it
if (function_exists('phpversion') && phpversion('imagick')) {
helper_watermark_imagick($name, $ext, $logo_path);
return;
}
#now, lets work and detect our image extension
if (strpos($ext, 'jp') !== false) {
$src_img = @imagecreatefromjpeg($name);
} elseif (strpos($ext, 'png') !== false) {
$src_img = @imagecreatefrompng($name);
} elseif (strpos($ext, 'gif') !== false) {
return;
$src_img = @imagecreatefromgif($name);
} elseif (strpos($ext, 'bmp') !== false) {
if (!defined('BMP_CLASS_INCLUDED')) {
include dirname(__FILE__) . '/BMP.php';
define('BMP_CLASS_INCLUDED', true);
}
$src_img = imagecreatefrombmp($name);
} else {
return;
}
#detect width, height for the image
$bwidth = @imageSX($src_img);
$bheight = @imageSY($src_img);
#detect width, height for the watermark image
$lwidth = @imageSX($src_logo);
$lheight = @imageSY($src_logo);
if ($bwidth > $lwidth + 5 && $bheight > $lheight + 5) {
#where exaxtly do we have to make the watermark ..
$src_x = $bwidth - ($lwidth + 5);
$src_y = $bheight - ($lheight + 5);
#make it now, watermark it
@ImageAlphaBlending($src_img, true);
@ImageCopy($src_img, $src_logo, $src_x, $src_y, 0, 0, $lwidth, $lheight);
if (strpos($ext, 'jp') !== false) {
@imagejpeg($src_img, $name);
} elseif (strpos($ext, 'png') !== false) {
@imagepng($src_img, $name);
} elseif (strpos($ext, 'gif') !== false) {
@imagegif($src_img, $name);
} elseif (strpos($ext, 'bmp') !== false) {
@imagebmp($src_img, $name);
}
} else {
#image is not big enough to watermark it
return false;
}
}
示例5: imagebmp
public static function imagebmp(&$img, $filename = false)
{
return imagebmp($img, $filename);
}
示例6: makeThumbWatermark
//.........这里部分代码省略.........
ImageCopyResampled($src_image, $img, 0, 0, 0, 0, $width, $height, $image_info["width"], $image_info["height"]);
} else {
$src_image = imagecreate($width, $height);
ImageCopyResized($src_image, $img, 0, 0, 0, 0, $width, $height, $image_info["width"], $image_info["height"]);
}
$src_image_w = ImageSX($src_image);
$src_image_h = ImageSY($src_image);
if ($this->wm_image_name) {
$wm_image_info = $this->getInfo($this->wm_image_name);
if (!$wm_image_info) {
return false;
}
$wm_image_type = $wm_image_info["type"];
$wm_image = $this->createImage($wm_image_type, $this->wm_image_name);
$wm_image_w = ImageSX($wm_image);
$wm_image_h = ImageSY($wm_image);
$temp_wm_image = $this->getPos($src_image_w, $src_image_h, $this->wm_image_pos, $wm_image);
if ($this->emboss && function_exists("imagefilter")) {
imagefilter($wm_image, IMG_FILTER_EMBOSS);
$bgcolor = imagecolorclosest($wm_image, 0x7f, 0x7f, 0x7f);
imagecolortransparent($wm_image, $bgcolor);
}
if (function_exists("ImageAlphaBlending") && IMAGETYPE_PNG == $wm_image_info['type']) {
ImageAlphaBlending($src_image, true);
}
$wm_image_x = $temp_wm_image["dest_x"];
$wm_image_y = $temp_wm_image["dest_y"];
if (IMAGETYPE_PNG == $wm_image_info['type']) {
imageCopy($src_image, $wm_image, $wm_image_x, $wm_image_y, 0, 0, $wm_image_w, $wm_image_h);
} else {
imageCopyMerge($src_image, $wm_image, $wm_image_x, $wm_image_y, 0, 0, $wm_image_w, $wm_image_h, $this->wm_image_transition);
}
}
if ($this->wm_text) {
$this->wm_text = $this->wm_text;
$temp_wm_text = $this->getPos($src_image_w, $src_image_h, $this->wm_image_pos);
$wm_text_x = $temp_wm_text["dest_x"];
$wm_text_y = $temp_wm_text["dest_y"];
if (preg_match("/([a-f0-9][a-f0-9])([a-f0-9][a-f0-9])([a-f0-9][a-f0-9])/i", $this->wm_text_color, $color)) {
$red = hexdec($color[1]);
$green = hexdec($color[2]);
$blue = hexdec($color[3]);
$wm_text_color = imagecolorallocate($src_image, $red, $green, $blue);
} else {
$wm_text_color = imagecolorallocate($src_image, 255, 255, 255);
}
imagettftext($src_image, $this->wm_text_size, $this->wm_angle, $wm_text_x, $wm_text_y, $wm_text_color, $this->wm_text_font, $this->wm_text);
}
if ($this->save_file) {
switch ($src_image_type) {
case 1:
if ($this->gif_enable) {
$src_img = ImageGIF($src_image, $this->save_file);
} else {
$src_img = ImagePNG($src_image, $this->save_file);
}
break;
case 2:
$src_img = ImageJPEG($src_image, $this->save_file, $this->jpeg_quality);
break;
case 3:
$src_img = ImagePNG($src_image, $this->save_file);
break;
default:
$src_img = ImageJPEG($src_image, $this->save_file, $this->jpeg_quality);
break;
}
} else {
switch ($src_image_type) {
case 1:
if ($this->gif_enable) {
header("Content-type: image/gif");
$src_img = ImageGIF($src_image);
} else {
header("Content-type: image/png");
$src_img = ImagePNG($src_image);
}
break;
case 2:
header("Content-type: image/jpeg");
$src_img = ImageJPEG($src_image, "", $this->jpeg_quality);
break;
case 3:
header("Content-type: image/png");
$src_img = ImagePNG($src_image);
break;
case 6:
header("Content-type: image/bmp");
$src_img = imagebmp($src_image);
break;
default:
header("Content-type: image/jpeg");
$src_img = ImageJPEG($src_image, "", $this->jpeg_quality);
break;
}
}
imagedestroy($src_image);
imagedestroy($img);
return true;
}
示例7: imagerotate
//print_r($data);
// Rotate
$degrees = 90;
$rotate = imagerotate($im, $degrees, 0);
switch ($type) {
case 1:
imagegif($rotate, $filepath, 100);
break;
case 2:
imagejpeg($rotate, $filepath, 100);
break;
case 3:
imagepng($rotate, $filepath, 100);
break;
case 6:
imagebmp($rotate, $filepath, 100);
break;
}
imagedestroy($im);
imagedestroy($rotate);
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title> Profile </title>
<meta name="mobile-web-app-capable" content="yes">
示例8: resizeImage
/**
* [resizeImage description]
* @param [type] $im [源目标图片]
* @param [type] $maxwidth [最大宽度]
* @param [type] $maxheight [最大高度]
* @param [type] $name [图片名]
* @param [type] $filetype [图片类型]
* @param [type] $tmp_name [上传的文件的临时路径]
* @return [type] [成功true]
*/
function resizeImage($tmp_name, $maxwidth, $maxheight, $name, $filetype)
{
try {
$img_info = getimagesize($tmp_name);
if (!in_array($img_info['mime'], array('image/jpeg', 'image/png', 'image/bmp', 'image/gif', 'image/pjpeg', 'image/jpg', 'image/x-png'))) {
$this->errmsg = '只支持上传图片';
return FALSE;
}
$pic_width = $img_info[0];
$pic_height = $img_info[1];
if ($maxwidth && $pic_width > $maxwidth || $maxheight && $pic_height > $maxheight) {
$resizeheightTag = $resizewidthTag = false;
if ($maxwidth && $pic_width > $maxwidth) {
$widthratio = $maxwidth / $pic_width;
$resizewidthTag = true;
}
if ($maxheight && $pic_height > $maxheight) {
$heightratio = $maxheight / $pic_height;
$resizeheightTag = true;
}
if ($resizewidthTag && $resizeheightTag) {
if ($widthratio < $heightratio) {
$ratio = $widthratio;
} else {
$ratio = $heightratio;
}
}
if ($resizewidthTag && !$resizeheightTag) {
$ratio = $widthratio;
}
if ($resizeheightTag && !$resizewidthTag) {
$ratio = $heightratio;
}
$newwidth = $pic_width * $ratio;
$newheight = $pic_height * $ratio;
$newim = imagecreatetruecolor($newwidth, $newheight);
switch ($img_info['mime']) {
case "image/gif":
$images = imagecreatefromgif($tmp_name);
break;
case "image/pjpeg":
case "image/jpeg":
case "image/jpg":
$images = imagecreatefromjpeg($tmp_name);
break;
case "image/png":
case "image/x-png":
$images = imagecreatefrompng($tmp_name);
break;
case "image/bmp":
$images = imageCreateFromBmp($tmp_name);
break;
}
imagecopyresampled($newim, $images, 0, 0, 0, 0, $newwidth, $newheight, $pic_width, $pic_height);
$name = $this->save_path . $name . $filetype;
switch ($img_info['mime']) {
case "image/gif":
imagegif($newim, $name);
break;
case "image/pjpeg":
case "image/jpeg":
case "image/jpg":
imagejpeg($newim, $name, 100);
break;
case "image/png":
case "image/x-png":
imagepng($newim, $name);
break;
case "image/bmp":
imagebmp($newim, $name);
break;
}
imagedestroy($newim);
} else {
if (!copy($tmp_name, $this->save_path . $name . $filetype)) {
return false;
}
}
return TRUE;
} catch (E $e) {
return FALSE;
}
}
示例9: to
public function to($src)
{
imagebmp($this->image, $src);
}
示例10: ImageResize
function ImageResize($srcFile, $toW, $toH, $toFile = "")
{
global $cfg_photo_type;
if ($toFile == '') {
$toFile = $srcFile;
}
$info = '';
$srcInfo = GetImageSize($srcFile, $info);
switch ($srcInfo[2]) {
case 1:
if (!$cfg_photo_type['gif']) {
return FALSE;
}
$im = imagecreatefromgif($srcFile);
break;
case 2:
if (!$cfg_photo_type['jpeg']) {
return FALSE;
}
$im = imagecreatefromjpeg($srcFile);
break;
case 3:
if (!$cfg_photo_type['png']) {
return FALSE;
}
$im = imagecreatefrompng($srcFile);
break;
case 6:
if (!$cfg_photo_type['bmp']) {
return FALSE;
}
$im = imagecreatefromwbmp($srcFile);
break;
}
$srcW = ImageSX($im);
$srcH = ImageSY($im);
if ($srcW <= $toW && $srcH <= $toH) {
return TRUE;
}
$toWH = $toW / $toH;
$srcWH = $srcW / $srcH;
if ($toWH <= $srcWH) {
$ftoW = $toW;
$ftoH = $ftoW * ($srcH / $srcW);
} else {
$ftoH = $toH;
$ftoW = $ftoH * ($srcW / $srcH);
}
if ($srcW > $toW || $srcH > $toH) {
if (function_exists("imagecreateTRUEcolor")) {
@($ni = imagecreateTRUEcolor($ftoW, $ftoH));
if ($ni) {
imagecopyresampled($ni, $im, 0, 0, 0, 0, $ftoW, $ftoH, $srcW, $srcH);
} else {
$ni = imagecreate($ftoW, $ftoH);
imagecopyresized($ni, $im, 0, 0, 0, 0, $ftoW, $ftoH, $srcW, $srcH);
}
} else {
$ni = imagecreate($ftoW, $ftoH);
imagecopyresized($ni, $im, 0, 0, 0, 0, $ftoW, $ftoH, $srcW, $srcH);
}
switch ($srcInfo[2]) {
case 1:
imagegif($ni, $toFile);
break;
case 2:
imagejpeg($ni, $toFile, 85);
break;
case 3:
imagepng($ni, $toFile);
break;
case 6:
imagebmp($ni, $toFile);
break;
default:
return FALSE;
}
imagedestroy($ni);
}
imagedestroy($im);
return TRUE;
}
示例11: replace_pictures
/**
* replaces all pictures of $this-user with a dummy for the given object-type
* @param int $object_type object_types-id from table object_types
* @return bool true, if replacement worked, false otherwise
*/
function replace_pictures($object_type)
{
// get optionsarray
global $opt;
// load bmp-support
require_once $opt['rootpath'] . 'lib2/imagebmp.inc.php';
// paths cleared by trailing '/'
if (substr($opt['logic']['pictures']['dir'], -1) != '/') {
$picpath = $opt['logic']['pictures']['dir'];
} else {
$picpath = substr($opt['logic']['pictures']['dir'], 0, -1);
}
$thumbpath = "{$picpath}/thumbs";
$pdummy = isset($opt['logic']['pictures']['dummy']);
if ($pdummy && isset($opt['logic']['pictures']['dummy']['bgcolor']) && is_array($opt['logic']['pictures']['dummy']['bgcolor'])) {
$dummybg = $opt['logic']['pictures']['dummy']['bgcolor'];
} else {
$dummybg = array(255, 255, 255);
}
if ($pdummy && isset($opt['logic']['pictures']['dummy']['text'])) {
$dummytext = $opt['logic']['pictures']['dummy']['text'];
} else {
$dummytext = '';
}
if ($pdummy && isset($opt['logic']['pictures']['dummy']['textcolor']) && is_array($opt['logic']['pictures']['dummy']['textcolor'])) {
$dummytextcolor = $opt['logic']['pictures']['dummy']['textcolor'];
} else {
$dummytextcolor = array(0, 0, 0);
}
$tmh = 0;
$tmw = 0;
/*
* check log or cache
*/
if ($object_type == OBJECT_CACHE) {
// get filenames of the pictures of $this' caches
$rs = sql("SELECT `pictures`.`url` " . "FROM `pictures`,`caches` " . "WHERE `caches`.`cache_id`=`pictures`.`object_id`" . " AND `pictures`.`object_type`='&1' AND `caches`.`user_id`='&2'", OBJECT_CACHE, $this->getUserId());
} elseif ($object_type == OBJECT_CACHELOG) {
// get filenames of the pictures of $this' logs
$rs = sql("SELECT `pictures`.`url` " . "FROM `pictures`,`cache_logs` " . "WHERE `cache_logs`.`id`=`pictures`.`object_id`" . " AND `pictures`.`object_type`='&1' AND `cache_logs`.`user_id`='&2'", OBJECT_CACHELOG, $this->getUserId());
}
// set thumb-dimensions
$tmh = $opt['logic']['pictures']['thumb_max_height'];
$tmw = $opt['logic']['pictures']['thumb_max_width'];
$filenames = array();
while ($url = sql_fetch_array($rs, MYSQL_NUM)) {
$filenames[] = substr($url['url'], -40);
}
// free result
sql_free_result($rs);
/*
* walk through filenames and replace original
*/
// check if there is something to replace
if (count($filenames) > 0) {
foreach ($filenames as $fn) {
// get uuid and extension
$uuid = substr($fn, 0, 36);
$ext = substr($fn, -3);
$thumb_dir1 = substr($uuid, 0, 1);
$thumb_dir2 = substr($uuid, 1, 1);
// read original size
if (file_exists("{$picpath}/{$fn}")) {
list($w, $h, $t, $attr) = getimagesize("{$picpath}/{$fn}");
} else {
$w = 600;
$h = 480;
}
// create new image
$im = imagecreatetruecolor($w, $h);
// allocate colors
$col_bg = imagecolorallocate($im, $dummybg[0], $dummybg[1], $dummybg[2]);
$col_text = imagecolorallocate($im, $dummytextcolor[0], $dummytextcolor[1], $dummytextcolor[2]);
// fill bg
imagefill($im, 0, 0, $col_bg);
// check for replacement-image
if ($pdummy && isset($opt['logic']['pictures']['dummy']['replacepic']) && $opt['logic']['pictures']['dummy']['replacepic'] != $opt['rootpath'] . 'images/' && file_exists($opt['logic']['pictures']['dummy']['replacepic'])) {
// get dimensions of the replacement
list($rw, $rh, $rt, $rattr) = getimagesize($opt['logic']['pictures']['dummy']['replacepic']);
$rwh = 0;
if ($rw > $rh) {
$rwh = $rh;
} else {
$rwh = $rw;
}
// check dimensions of original and set replacement size
$rsize = 0;
if ($w > $h) {
if ($h * 0.85 > $rwh) {
$rsize = $rwh;
} else {
$rsize = $h * 0.9;
}
} else {
if ($w * 0.85 > $rwh) {
//.........这里部分代码省略.........
示例12: imagecreatefromjpeg
$img = imagecreatefromjpeg($fil);
$new_image_ext = 'jpg';
}
if ($sorthvid == "1") {
imagefilter($img, IMG_FILTER_GRAYSCALE);
}
imagefilter($img, IMG_FILTER_BRIGHTNESS, $lysbalance);
imagefilter($img, IMG_FILTER_CONTRAST, $kontrast);
switch ($type) {
case 'jpeg':
imagejpeg($img, $fil);
break;
case 'png':
imagepng($img, $fil);
break;
case 'bmp':
imagebmp($img, $fil);
break;
case 'gif':
imagegif($img, $fil);
break;
case 'vnd.wap.wbmp':
imagewbmp($img, $fil);
break;
case 'xbm':
imagexbm($img, $fil);
break;
default:
imagejpeg($img, $fil);
}
imagedestroy($img);
示例13: imagecopyresampled
} else {
$newheight = $height;
}
$destimg = @imagecreatetruecolor(100, $newheight);
imagecopyresampled($destimg, $orig_image, 0, 0, 0, 0, 100, $newheight, imagesx($orig_image), imagesy($orig_image));
if ($ext == 'jpg' or $ext == 'jpeg') {
@imagejpeg($destimg, $dl->url . $thumb);
} else {
if ($ext == 'png') {
@imagepng($destimg, $dl->url . $thumb);
} else {
if ($ext == 'gif') {
@imagegif($destimg, $dl->url . $thumb);
} else {
if ($ext == 'bmp') {
@imagebmp($destimg, $dl->url . $thumb);
}
}
}
}
@imagedestroy($destimg);
$db->query_write("INSERT INTO " . TABLE_PREFIX . "dl_images (`file`,`name`,`thumb`,`uploader`,`uploaderid`,`date`) VALUES(" . $file['id'] . "," . $db->sql_prepare($newfilename) . "," . $db->sql_prepare($thumb) . "," . $db->sql_prepare($vbulletin->userinfo['username']) . "," . $vbulletin->userinfo['userid'] . "," . $db->sql_prepare(TIMENOW) . ")");
eval(print_standard_redirect('ecdownloads_msg_image_added', true, true));
}
}
if ($_GET['act'] == 'delimg') {
$image = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "dl_images WHERE `id` = " . $db->sql_prepare($_GET['img']));
if ($permissions['ecdownloadpermissions'] & $vbulletin->bf_ugp['ecdownloadpermissions']['caneditallfiles'] or $permissions['ecdownloadpermissions'] & $vbulletin->bf_ugp['ecdownloadpermissions']['caneditownfiles'] and ($image['uploaderid'] == $vbulletin->userinfo['userid'] and $file['uploaderid'] == $vbulletin->userinfo['userid'])) {
$db->query_write("DELETE FROM " . TABLE_PREFIX . "dl_images WHERE `id` = " . $db->sql_prepare($image['id']));
@unlink($dl->url . $image['name']);
@unlink($dl->url . $image['thumb']);
示例14: img_thumb
function img_thumb($target, $newcopy, $w, $h, $ext)
{
list($w_orig, $h_orig) = getimagesize($target);
// get image sizes of the uploaded image
$wr = $w_orig / $w;
// get the width ratio
$hr = $h_orig / $h;
// get the height ratio
$src_x = 0;
// start our crop x source at 0
$src_y = 0;
// start our crop y source at 0
// figure out if we need to crop the height or width to match our destination size ratio
if ($hr < $wr) {
// perform if the height is the limiting factor
$ow = $w_orig;
// store our original width for later use
$w_orig = $w * $hr;
// new original width
$src_x = ($ow - $w_orig) / 2;
// our new value to center crop the width
}
if ($wr < $hr) {
// perform if the width is the limiting factor
$oh = $h_orig;
// store our original width for later use
$h_orig = $h * $wr;
// new original height
$src_y = ($oh - $h_orig) / 2;
// our new value to center crop the height
}
$ext = strtolower($ext);
$img = "";
if ($ext == "gif") {
$img = imagecreatefromgif($target);
} else {
if ($ext == "png") {
$img = imagecreatefrompng($target);
} else {
$img = imagecreatefromjpeg($target);
}
}
$tci = imagecreatetruecolor($w, $h);
if ($ext == "gif" or $ext == "png") {
imagecolortransparent($tci, imagecolorallocatealpha($tci, 0, 0, 0, 127));
imagealphablending($tci, false);
imagesavealpha($tci, true);
}
imagecopyresampled($tci, $img, 0, 0, $src_x, $src_y, $w, $h, $w_orig, $h_orig);
// if($src_x<0) {
// $bgd = imagecolorallocate($tci, 255, 255, 255);
// imagefill($tci, 0, 0, $bgd);
// }
if ($ext == "gif") {
imagegif($tci, $newcopy);
} else {
if ($ext == "png") {
imagepng($tci, $newcopy);
} else {
if ($ext == "bmp") {
imagebmp($tci, $newcopy);
} else {
imagejpeg($tci, $newcopy, 84);
}
}
}
}
示例15: check_imagick_rotate
function check_imagick_rotate()
{
$pic_path = MooGetGPC('pic_path', 'string', 'G');
$id = MooGetGPC('id', 'integer', 'G');
$uid = MooGetGPC('uid', 'integer', 'G');
$degrees = 90;
$file = explode('.', $pic_path);
// var_dump($file);exit;
$new_file = '../' . $file[0] . '.' . $file[1];
$pic_path = '../' . $pic_path;
$source = imagecreatefromjpeg($pic_path);
$rotate = imagerotate($source, $degrees, 0);
// var_dump($pic_path);
list($imagewidth, $imageheight, $imageType) = getimagesize($pic_path);
$imageType = image_type_to_mime_type($imageType);
switch ($imageType) {
case "image/gif":
imagegif($rotate, $new_file, 100);
break;
case "image/pjpeg":
case "image/jpeg":
case "image/jpg":
imagejpeg($rotate, $new_file, 100);
break;
case "image/png":
case "image/x-png":
imagepng($rotate, $new_file, 100);
break;
case "image/bmp":
imagebmp($rotate, $new_file, 100);
break;
}
//var_dump($new_file);exit;
header('location:index.php?action=check&h=photo&type=show&id=100004&uid=100004');
}