本文整理汇总了PHP中ImageHelper::ImageCreateFromBMP方法的典型用法代码示例。如果您正苦于以下问题:PHP ImageHelper::ImageCreateFromBMP方法的具体用法?PHP ImageHelper::ImageCreateFromBMP怎么用?PHP ImageHelper::ImageCreateFromBMP使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageHelper
的用法示例。
在下文中一共展示了ImageHelper::ImageCreateFromBMP方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionPhoto
public function actionPhoto($id)
{
$model = $this->loadModel($id);
$model->scenario = 'photo';
Yii::trace("FC.actionPhoto called", 'application.controllers.FamilyController');
if (Yii::app()->params['photoManip']) {
if (isset($_POST['x1'])) {
$x1 = $_POST['x1'];
$y1 = $_POST['y1'];
$width = $_POST['width'];
$height = $_POST['height'];
$pfile = $_POST['pfile'];
$sdir = './images/uploaded/';
$size = getimagesize($sdir . $pfile);
if ($size) {
list($w, $h, $t) = $size;
} else {
Yii::trace("FR.actionPhoto crop call to getimagesize failed for image " . $sdir . $pfile . " returned {$size}", 'application.controllers.FamilyController');
}
Yii::trace("FC.actionPhoto crop received {$x1}, {$y1}, {$width}, {$height}, {$w}, {$h}, {$t}", 'application.controllers.FamilyController');
switch ($t) {
case 1:
$img = imagecreatefromgif($sdir . $pfile);
break;
case 2:
$img = imagecreatefromjpeg($sdir . $pfile);
break;
case 3:
$img = imagecreatefrompng($sdir . $pfile);
break;
case IMAGETYPE_BMP:
$img = ImageHelper::ImageCreateFromBMP($sdir . $pfile);
break;
case IMAGETYPE_WBMP:
$img = imagecreatefromwbmp($sdir . $pfile);
break;
default:
Yii::trace("FC.actionPhoto crop unknown image type {$t}", 'application.controllers.FamilyController');
}
if (function_exists('imagecrop')) {
# untested
$cropped = imagecrop($img, array('x1' => $x1, 'y1' => $y1, 'width' => $width, 'height' => $height));
$scaled = imagescale($cropped, 400);
} else {
$h = $height * 400 / $width;
$scaled = imagecreatetruecolor(400, $h);
imagecopyresized($scaled, $img, 0, 0, $x1, $y1, 400, $h, $width, $height);
}
$dir = './images/families/';
$fname = preg_replace('/\\.[a-z]+$/i', '', $pfile);
$fext = ".jpg";
if (file_exists($dir . $pfile)) {
$fname .= "_01";
while (file_exists($dir . $fname . $fext)) {
++$fname;
}
}
$dest = $dir . $fname . $fext;
imagejpeg($scaled, $dest, 90);
imagedestroy($scaled);
imagedestroy($img);
unlink($sdir . $pfile);
$model->photo = $fname . $fext;
$model->save(false);
Yii::trace("FC.actionPhoto saved to {$pfile}", 'application.controllers.FamilyController');
$this->redirect(array('view', 'id' => $model->id));
return;
} elseif (isset($_FILES['Families'])) {
Yii::trace("FC.actionPhoto _FILES[Families] set", 'application.controllers.FamilyController');
$files = $_FILES['Families'];
$filename = $files['name']['raw_photo'];
if (isset($filename) and '' != $filename) {
Yii::trace("FC.actionPhoto filename {$filename}", 'application.controllers.FamilyController');
$tmp_path = $files['tmp_name']['raw_photo'];
if (isset($tmp_path) and '' != $tmp_path) {
Yii::trace("FC.actionPhoto tmp_path {$tmp_path}", 'application.controllers.FamilyController');
$dir = "./images/uploaded/";
$dest = $dir . $filename;
list($width, $height) = getimagesize($tmp_path);
if ($width < 900) {
$w = $width;
$h = $height;
$zoom = 1;
} else {
$w = 900;
$h = $height * 900 / $width;
$zoom = $w / $width;
}
$w = $width < 900 ? $width : 900;
move_uploaded_file($tmp_path, $dest);
$this->render('crop', array('model' => $model, 'pfile' => $filename, 'width' => $w, 'height' => $h, 'zoom' => $zoom));
return;
} else {
$errors = array(1 => "Size exceeds max_upload", 2 => "FORM_SIZE", 3 => "No tmp dir", 4 => "can't write", 5 => "error extension", 6 => "error partial");
$error = $errors[$files['error']['raw_photo']];
Yii::trace("FC.actionPhoto file error {$error}", 'application.controllers.FamilyController');
}
}
}
} elseif (isset($_FILES['Families'])) {
//.........这里部分代码省略.........