本文整理汇总了PHP中Image::height方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::height方法的具体用法?PHP Image::height怎么用?PHP Image::height使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image::height方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public static function run(\Image $res, $settings)
{
$resource = $res->Resource();
$dst_w = Image::width($resource);
$dst_h = Image::height($resource);
$width = $settings['settings']['width'];
$height = $settings['settings']['height'];
if (!empty($width) && !empty($height)) {
$dst_w = $width;
$dst_h = $height;
} elseif (empty($height)) {
$ratio = $dst_h / $dst_w;
$dst_w = $width;
$dst_h = round($dst_w * $ratio);
} elseif (empty($width)) {
$ratio = $dst_w / $dst_h;
$dst_h = $height;
$dst_w = round($dst_h * $ratio);
}
$tmp = imagecreatetruecolor($dst_w, $dst_h);
self::__fill($resource, $tmp, $settings['settings']['background']);
imagecopyresampled($tmp, $resource, 0, 0, 0, 0, $dst_w, $dst_h, Image::width($resource), Image::height($resource));
if (is_resource($resource)) {
imagedestroy($resource);
}
$res->setResource($tmp);
return $res;
}
示例2: run
public static function run($res, $width, $height, $anchor = self::TOP_LEFT, $background_fill = null)
{
$dst_w = Image::width($res);
$dst_h = Image::height($res);
if (!empty($width) && !empty($height)) {
$dst_w = $width;
$dst_h = $height;
} else {
if (empty($height)) {
$ratio = $dst_h / $dst_w;
$dst_w = $width;
$dst_h = round($dst_w * $ratio);
} else {
if (empty($width)) {
$ratio = $dst_w / $dst_h;
$dst_h = $height;
$dst_w = round($dst_h * $ratio);
}
}
}
$tmp = imagecreatetruecolor($dst_w, $dst_h);
self::__fill($res, $tmp, $background_fill);
$image_width = Image::width($res);
$image_height = Image::height($res);
list($src_x, $src_y, $dst_x, $dst_y) = self::__calculateDestSrcXY($dst_w, $dst_h, $image_width, $image_height, $image_width, $image_height, $anchor);
imagecopyresampled($tmp, $res, $src_x, $src_y, $dst_x, $dst_y, $image_width, $image_height, $image_width, $image_height);
if (is_resource($res)) {
imagedestroy($res);
}
return $tmp;
}
示例3: run
public static function run($res, $width = NULL, $height = NULL)
{
$dst_w = Image::width($res);
$dst_h = Image::height($res);
if (!empty($width) && !empty($height)) {
$dst_w = $width;
$dst_h = $height;
} elseif (empty($height)) {
$ratio = $dst_h / $dst_w;
$dst_w = $width;
$dst_h = round($dst_w * $ratio);
} elseif (empty($width)) {
$ratio = $dst_w / $dst_h;
$dst_h = $height;
$dst_w = round($dst_h * $ratio);
}
$dst = imagecreatetruecolor($dst_w, $dst_h);
/* making the new image transparent */
$background = imagecolorallocate($dst, 0, 0, 0);
ImageColorTransparent($dst, $background);
// make the new temp image all transparent
imagealphablending($dst, false);
imagesavealpha($dst, true);
imageAntiAlias($dst, true);
self::__fill($dst);
imagecopyresampled($dst, $res, 0, 0, 0, 0, $dst_w, $dst_h, Image::width($res), Image::height($res));
@imagedestroy($res);
return $dst;
}
示例4: resize
function resize($path, $opt)
{
$f3 = \Base::instance();
$hash = $f3->hash($path . $f3->serialize($opt));
$new_file_name = $hash . '.jpg';
$dst_path = $f3->get('UPLOADS') . 'img/';
$path = explode('/', $path);
$file = array_pop($path);
if (!is_dir($dst_path)) {
mkdir($dst_path, 0775);
}
if (!file_exists($dst_path . $new_file_name)) {
$imgObj = new \Image($file, false, implode('/', $path) . '/');
$ow = $imgObj->width();
$oh = $imgObj->height();
if (!$opt['width']) {
$opt['width'] = round($opt['height'] / $oh * $ow);
}
if (!$opt['height']) {
$opt['height'] = round($opt['width'] / $ow * $oh);
}
$imgObj->resize((int) $opt['width'], (int) $opt['height'], $opt['crop'], $opt['enlarge']);
$file_data = $imgObj->dump('jpeg', null, $opt['quality']);
$f3->write($dst_path . $new_file_name, $file_data);
}
return $dst_path . $new_file_name;
}
示例5: run
public static function run(\Image $res, $settings)
{
$resource = $res->Resource();
$percentage = floatval(max(1.0, floatval($settings['settings']['percentage'])) * 0.01);
$settings['settings']['width'] = round(Image::height($resource) * $percentage);
return parent::run($res, $settings);
}
示例6: putWatermarkInTiles
public function putWatermarkInTiles(Image $wm, $hide = 100)
{
for ($y = 0; $y < $this->height(); $y += $wm->height()) {
for ($x = 0; $x < $this->width(); $x += $wm->width()) {
$this->putWatermark($wm, $hide, $x, $y);
}
}
}
示例7: run
public static function run(\Image $res, $settings)
{
$src_w = $res->Meta()->width;
$src_h = $res->Meta()->height;
if ($settings['settings']['height'] == 0) {
$ratio = $src_h / $src_w;
$dst_h = round($settings['meta']['width'] * $ratio);
} elseif ($settings['settings']['width'] == 0) {
$ratio = $src_w / $src_h;
$dst_w = round($settings['meta']['height'] * $ratio);
}
$src_r = $src_w / $src_h;
$dst_r = $settings['meta']['width'] / $settings['meta']['height'];
if ($src_r < $dst_r) {
$width = $settings['meta']['width'];
$height = null;
} else {
$width = null;
$height = $settings['meta']['height'];
}
$resource = $res->Resource();
$dst_w = Image::width($resource);
$dst_h = Image::height($resource);
if (!empty($width) && !empty($height)) {
$dst_w = $width;
$dst_h = $height;
} elseif (empty($height)) {
$ratio = $dst_h / $dst_w;
$dst_w = $width;
$dst_h = round($dst_w * $ratio);
} elseif (empty($width)) {
$ratio = $dst_w / $dst_h;
$dst_h = $height;
$dst_w = round($dst_h * $ratio);
}
$image_width = Image::width($resource);
$image_height = Image::height($resource);
$tmp = imagecreatetruecolor($dst_w, $dst_h);
self::__fill($resource, $tmp, $settings['settings']['background']);
list($src_x, $src_y, $dst_x, $dst_y) = self::__calculateDestSrcXY($dst_w, $dst_h, $image_width, $image_height, $image_width, $image_height, $settings['settings']['position']);
imagecopyresampled($tmp, $resource, $src_x, $src_y, $dst_x, $dst_y, $image_width, $image_height, $image_width, $image_height);
if (is_resource($resource)) {
imagedestroy($resource);
}
$res->setResource($tmp);
return $res;
}
示例8: saveImage
public function saveImage()
{
$this->allowtypes = array('jpg', 'jpeg', 'png', 'gif');
$this->maxsize = 1024 * 1024 * 5;
$filename = $this->setfilename();
$filepath = date('Y') . '/' . date('m') . '/' . $filename;
$thumb = 'thumb/' . $filepath;
$attachment = 'photo/' . $filepath;
if ($this->save(C('ATTACHDIR') . $attachment)) {
$image = new Image(C('ATTACHDIR') . $attachment);
$image->thumb(210, 210);
$image->save(C('ATTACHDIR') . $thumb);
return array('name' => $filename, 'width' => $image->width(), 'height' => $image->height(), 'type' => $image->type(), 'filesize' => $this->size(), 'attachment' => $attachment, 'thumb' => $thumb);
} else {
return false;
}
}
示例9: correct
function correct($path)
{
// Уменьшаем до максимально допустимых размеров
//var_dump($path);
$img = new \Image($path);
$img->resize(1500, 1500, false, false);
if ($this->fw->get('site.use_watermark')) {
$overlay = new \Image('../' . APP_FOLDER . '/views/' . $this->fw->get('site.tpl') . '/watermark.png');
$overlay->resize(1500, 1500, true, false);
$img->overlay($overlay, (int) $this->fw->get('site.watermark.x') | (int) $this->fw->get('site.watermark.y'));
} elseif ($this->fw->get('site.use_text_watermark')) {
// Создаём изображение-оверлей с надписью
$wm = $this->createTextWatermark($img->width(), $img->height());
$overlay = new \Image($wm);
// 2 добавить его к текущему изборажению
$img->overlay($overlay, \Image::POS_Center | \Image::POS_Middle);
}
$this->fw->write($path, $img->dump());
}
示例10: run
public static function run($res, $width, $height, $anchor = self::TOP_LEFT, $background_fill = 'fff')
{
$dst_w = Image::width($res);
$dst_h = Image::height($res);
if (!empty($width) && !empty($height)) {
$dst_w = $width;
$dst_h = $height;
} elseif (empty($height)) {
$ratio = $dst_h / $dst_w;
$dst_w = $width;
$dst_h = round($dst_w * $ratio);
} elseif (empty($width)) {
$ratio = $dst_w / $dst_h;
$dst_h = $height;
$dst_w = round($dst_h * $ratio);
}
$tmp = imagecreatetruecolor($dst_w, $dst_h);
self::__fill($tmp, $background_fill);
list($src_x, $src_y, $dst_x, $dst_y) = self::__calculateDestSrcXY($dst_w, $dst_h, Image::width($res), Image::height($res), Image::width($res), Image::height($res), $anchor);
imagecopyresampled($tmp, $res, $src_x, $src_y, $dst_x, $dst_y, Image::width($res), Image::height($res), Image::width($res), Image::height($res));
@imagedestroy($res);
return $tmp;
// self::__copy($tmp, $res, true);
}
示例11: run
public static function run($res, $width = NULL, $height = NULL)
{
$dst_w = Image::width($res);
$dst_h = Image::height($res);
if (!empty($width) && !empty($height)) {
$dst_w = $width;
$dst_h = $height;
} elseif (empty($height)) {
$ratio = $dst_h / $dst_w;
$dst_w = $width;
$dst_h = round($dst_w * $ratio);
} elseif (empty($width)) {
$ratio = $dst_w / $dst_h;
$dst_h = $height;
$dst_w = round($dst_h * $ratio);
}
$dst = imagecreatetruecolor($dst_w, $dst_h);
//imagealphablending( $dst, false );
//imagesavealpha( $dst, true );
self::__fill($dst);
imagecopyresampled($dst, $res, 0, 0, 0, 0, $dst_w, $dst_h, Image::width($res), Image::height($res));
@imagedestroy($res);
return $dst;
}
示例12: Image
<?php
include './Image.php';
echo '<pre>';
$img = '/tmp/20151005/5613e8ca1832d87cb24a35a89b178fca.jpg';
$image = new Image(Image::IMAGE_GD);
//GD库处理
$image->open($img);
/******************************获取图像信息**********************************************************************************************/
$width = $image->width();
// 返回图片的宽度
$height = $image->height();
// 返回图片的高度
$type = $image->type();
// 返回图片的类型
$mime = $image->mime();
// 返回图片的mime类型
$size = $image->size();
// 返回图片的尺寸数组 0 图片宽度 1 图片高度
/******************************生成缩略图,按照原图的比例生成一个最大为150*150的缩略图并保存为thumb.jpg******************************************/
//$image->thumb(150, 150)->save('/tmp/20151005/thumb.jpg');//我们看到实际生成的缩略图并不是150*150,因为默认采用原图等比例缩放的方式生成缩略图,最大宽度是150。
/* IMAGE_THUMB_SCALE = 1 ; //等比例缩放类型(默认)
IMAGE_THUMB_FILLED = 2 ; //缩放后填充类型
IMAGE_THUMB_CENTER = 3 ; //居中裁剪类型
IMAGE_THUMB_NORTHWEST = 4 ; //左上角裁剪类型
IMAGE_THUMB_SOUTHEAST = 5 ; //右下角裁剪类型
IMAGE_THUMB_FIXED = 6 ; //固定尺寸缩放类型 */
/******************************添加图片水印*************************************************************************************************/
/* $image->crop(440, 440)->save('/tmp/20151005/crop.jpg');//将图片裁剪为440x440并保存为corp.jpg
$image->water('/tmp/20151005/logo.png')->save("/tmp/20151005/water.gif");// 给裁剪后的图片添加图片水印(水印文件位于./logo.png),位置为右下角,保存为water.gif
示例13: exit
//Upload de la photo selectionnée
if ($_FILES['photo_' . $group['id']]['tmp_name'] != null) {
$photos_dir = '../images/groupes/';
$tmp_file = $_FILES['photo_' . $group['id']]['tmp_name'];
if (!is_uploaded_file($tmp_file)) {
exit("Le fichier uploadé est introuvalbe");
}
//Vérification extension
$type_file = $_FILES['photo_' . $group['id']]['type'];
if (!strstr($type_file, 'jpg') && !strstr($type_file, 'jpeg') && !strstr($type_file, 'bmp') && !strstr($type_file, 'gif') && !strstr($type_file, 'png')) {
exit("Le fichier n'est pas une image");
}
//copie dans le dossier de destination
$name_file = 'photo_' . $group['id'] . '.jpg';
if (preg_match('#[\\x00-\\x1F\\x7F-\\x9F/\\\\]#', $name_file)) {
exit("Nom de fichier non valide");
} else {
if (!move_uploaded_file($tmp_file, $photos_dir . $name_file)) {
exit("Impossible de coier le fichier dans {$photos_dir}");
}
}
$thumb = new Image($photos_dir . $name_file);
$thumb->height(200);
$thumb->width(268);
$thumb->save();
// => fichier uploadé
}
mysql_query("UPDATE groups SET\tname='" . $_POST['name_' . $group['id']] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tnbr='" . $_POST['nbr_' . $group['id']] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\thorraire='" . $_POST['horraire_' . $group['id']] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tage='" . $_POST['age_' . $group['id']] . "'\n\t\t\t\t\t\t\t\t\t\t\tWHERE id='" . $group['id'] . "'") or die(mysql_error());
header('Location: ../index.php?p=groupes');
}
mysql_close($connexion);
示例14: run
public static function run($res, $percentage)
{
$percentage = floatval(max(1.0, floatval($percentage)) * 0.01);
$width = round(Image::height($res) * $percentage);
return self::resize($res, $width, NULL);
}
示例15: dirname
define('CARD_DIR', dirname(__FILE__) . '/card');
define('SOURCE_DIR', dirname(__FILE__) . '/source');
define('SPOIL_CARD', '_');
define('WIDTH', 140);
define('HEIGHT', 105);
$cutRange = [[248, 270], [248, 540], [248, 810], [248, 1080], [1323, 270], [1323, 540], [1323, 810], [1323, 1080]];
$images = ['img51.jpg', 'img54.jpg', 'img57.jpg', 'img60.jpg', 'img63.jpg'];
$cardnum = [0, 0, 2, 3, 4, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 14, 16, 19, 17, 18, 20, 22, 23, 24, 25, 26, 28, 29, 27, 31, 33, 35, 36, 21, 32, 30, 34, 0, 0];
$count = 0;
foreach ($images as $imgname) {
foreach ($cutRange as $r) {
list($x, $y) = $r;
$thumb = new Image(SOURCE_DIR . '/' . $imgname);
$thumb->width(WIDTH);
$thumb->height(HEIGHT);
$thumb->crop($x, $y);
$thumb->dir(CARD_DIR);
$name = $cardnum[$count++];
$thumb->name($name == 0 ? SPOIL_CARD : $name);
$thumb->save();
}
}
// 消費財
$thumb = new Image(SOURCE_DIR . '/' . 'img63.jpg');
$thumb->width(WIDTH);
$thumb->height(HEIGHT);
$thumb->crop(1323, 1110);
$thumb->dir(CARD_DIR);
$thumb->name('99');
$thumb->save();
unlink(CARD_DIR . '/' . SPOIL_CARD . '.jpg');