本文整理汇总了PHP中SimpleImage::watermark方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleImage::watermark方法的具体用法?PHP SimpleImage::watermark怎么用?PHP SimpleImage::watermark使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleImage
的用法示例。
在下文中一共展示了SimpleImage::watermark方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadArquivo
function uploadArquivo($campoFormulario, $idGravado) {
$ext = pathinfo($_FILES[$campoFormulario][name], PATHINFO_EXTENSION);
if (($_FILES[$campoFormulario][name] <> "") && ($_FILES[$campoFormulario][size]) > 0 && in_array(strtolower($ext), $this->extensions)) {
$arquivoTmp = $_FILES[$campoFormulario]['tmp_name'];
$nome = str_replace(".", "", microtime(true)) . "_" . $_FILES[$campoFormulario]['name'];
if (function_exists("exif_imagetype")) {
$test = exif_imagetype($arquivoTmp);
$image_type = $test;
} else {
$test = getimagesize($arquivoTmp);
$image_type = $test[2];
}
if (in_array($image_type, array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP))) {
$image = new SimpleImage();
$image->load($arquivoTmp);
$l = $image->getWidth();
$h = $image->getHeight();
if ($l > $h) {
$funcao = "resizeToWidth";
$novoTamanho = 1024;
} else {
$funcao = "resizeToHeight";
$novoTamanho = 768;
}
$image->$funcao($novoTamanho);
$copiou = $image->save($this->diretorio . $nome);
if ($this->prefixoMarcaDagua) {
$image->$funcao(300);
$image->watermark();
$image->save($this->diretorio . $this->prefixoMarcaDagua . $nome);
}
if ($this->prefixoMiniatura) {
$image->load($arquivoTmp);
$image->$funcao(380);
$image->save($this->diretorio . $this->prefixoMiniatura . $nome);
}
} else {
$copiou = copy($arquivoTmp, $this->diretorio . $nome);
}
if ($copiou) {
$sql = "update $this->tabela set $this->campoBD = '$nome' where id='$idGravado'";
#$altualizaNome = mysql_query($sql) or die($sql . mysql_error);
$this->conexao->executeQuery($sql);
}
} else {
return false;
}
return $idGravado;
}
示例2: array
$req_wall =& new HTTP_Request($_POST["wall_upload_url"]);
$req_wall->setMethod(HTTP_REQUEST_METHOD_POST);
}
if ($_POST["album"] != NULL) {
// Если мы нарезаем альбом, то используем другой принцип нарезки
if ($zip->open($arch, ZIPARCHIVE::CREATE) === TRUE) {
$res['upload_result'] = array();
for ($i = 0; $i < 3; $i++) {
for ($j = 0; $j < 4; $j++) {
$num++;
$filename_new = "photo/" . $i . "-" . $j . "_" . $filename;
$image->load("photo/" . $filename);
$image->copyImage($left[$j], $top[$i], $crop_width, $crop_height);
if ($num == 7) {
$watermark = imagecreatefrompng("images/watermark_album.png");
$image->watermark($image->image, $watermark, 80);
imagedestroy($watermark);
}
$image->save($filename_new);
$zip->addFile($filename_new, $num . "." . $filetype);
$req_album->addFile('file' . $j, $filename_new, 'image/' . $filetype);
}
$req_album->sendRequest();
$res['upload_result'][] = json_decode($req_album->getResponseBody());
$req_album =& new HTTP_Request($_POST["upload_url"]);
$req_album->setMethod(HTTP_REQUEST_METHOD_POST);
}
$zip->close();
$res['arch'] = $arch;
print json_encode($res);
}
示例3: resizeImage
public static function resizeImage($file, $folder, $width = 120, $height = 120, $iparams = array(), $loc_ext_name_com = null)
{
global $ext_name, $ext_name_com;
$loc_ext_name_com = !empty($loc_ext_name_com) ? $loc_ext_name_com : $ext_name_com;
$params = JComponentHelper::getParams($loc_ext_name_com);
if (!isset($iparams['displace'])) {
$iparams['displace'] = $params->get('displace', 0);
}
if (!isset($iparams['watermark'])) {
$iparams['watermark'] = $params->get('watermark', 0);
}
if (!isset($iparams['halign'])) {
$iparams['halign'] = $params->get('halign', 'center');
}
if (!isset($iparams['valign'])) {
$iparams['valign'] = $params->get('valign', 'middle');
}
$iparams['watermark_type'] = $params->get('watermark_type', 0);
$iparams['watermark_valign'] = $params->get('watermark_valign', 'middle');
$iparams['watermark_halign'] = $params->get('watermark_halign', 'center');
$iparams['background_type'] = $params->get('background_type', 'file');
natsort($iparams);
$dst_file = basename($file);
foreach ($iparams as $iparam) {
$dst_file = JString::str_ireplace('/', '.', $iparam) . '-' . $dst_file;
}
if (!class_exists('SimpleImage')) {
require dirname(__FILE__) . DS . '..' . DS . 'additional' . DS . 'simpleimage.php';
}
/*
if($width == 0) {
$width = $params->get('thumb_width', 120);
}*/
if ($height == 0) {
$height = $params->get('thumb_height', 120);
}
$dst_path_segments = array('media', $loc_ext_name_com, 'images', $folder, 'w' . $width . 'x' . 'h' . $height);
$dst_path = JPATH_ROOT;
foreach ($dst_path_segments as $v) {
$dst_path .= DS . $v;
if (!JFolder::exists($dst_path)) {
JFolder::create($dst_path);
chmod($dst_path, 0777);
}
}
$file != '' ? $dst_filename = $dst_path . DS . $dst_file : ($dst_filename = $dst_path . DS . 'no.jpg');
if (!JFile::exists($dst_filename)) {
if ($file != '') {
$src_filename = JPATH_ROOT . DS . 'media' . DS . $loc_ext_name_com . DS . 'images' . DS . $folder . DS . 'original' . DS . basename($file);
} else {
$src_filename = JPATH_ROOT . DS . 'media' . DS . $loc_ext_name_com . DS . 'images' . DS . $folder . DS . 'no.jpg';
}
if (!JFile::exists($src_filename)) {
$src_filename = JPATH_ROOT . DS . 'media' . DS . $loc_ext_name_com . DS . 'images' . DS . $folder . DS . 'no.jpg';
}
$image = new SimpleImage($src_filename);
if ($width == 0) {
$ratio = $height / $image->get_height();
$width = $image->get_width() * $ratio;
}
if ($image->get_width() > $width || $image->get_height() > $height) {
$ratio_in = $image->get_width() / $image->get_height();
if ($iparams['displace'] == 0) {
$ratio_out = $width / $height;
if ($ratio_in > $ratio_out) {
$image->resize((int) $width * $ratio_in, $height);
} else {
$image->resize($width, $width / $ratio_in);
}
$x1 = 0;
$y1 = 0;
switch ($iparams['halign']) {
case 'center':
$x1 = round($image->get_width() / 2 - $width / 2);
break;
case 'right':
$x1 = round($image->get_width() - $width);
break;
}
switch ($iparams['valign']) {
case 'middle':
$y1 = round($image->get_height() / 2 - $height / 2);
break;
case 'bottom':
$y1 = round($image->get_height() - $height);
break;
}
$image->crop($x1, $y1, $x1 + $width, $y1 + $height);
} else {
if ($width / $ratio_in > $height) {
$image->resize($height * $ratio_in, $height);
} else {
$image->resize($width, $width / $ratio_in);
}
}
}
if ($iparams['watermark'] == 1) {
$watermark_image = $params->get('watermark_image', '');
if (file_exists(JPATH_ROOT . DS . $watermark_image) && is_file(JPATH_ROOT . DS . $watermark_image)) {
$image->watermark(JPATH_ROOT . DS . $watermark_image, $iparams);
//.........这里部分代码省略.........