Example #1
1
header('Content-Type:text/html; charset=utf-8');
require_once "Config/Functions.php";
//$imgpath = 'http://imglocal.boqiicdn.com/Data/Vet/C/1404/21/img66921398048759_420x300.jpg';
// 图片路径
$imgpath = $_GET['path'];
if (!$imgpath) {
    echo '请传入需要处理的图片!';
    exit;
}
// 待处理图片
$oimgpath = $imgpath;
//$oimgpath = str_replace(str_replace(strrchr($imgpath, ".") , '', strrchr($imgpath, "_")), '', $imgpath);
$data['picurl'] = $oimgpath;
// 待处理图片地址
$data['type'] = 'watermark';
$result = watermark($data);
if ($result['status'] == 'error') {
    echo $result['tip'];
    exit;
} else {
    echo '<img src="' . $imgpath . '">';
    exit;
}
/**
 * 图片截取
 */
function watermark($param)
{
    //图片目录
    if (in_array($_SERVER['HTTP_HOST'], array("imglocal.boqii.com", "imglocal.boqiicdn.com"))) {
        $imgdir = 'http://imglocal.boqii.com';
Example #2
0
 //create thumb ?!
 if (${$InputName_ImageResize} == 1 && ${$InputName_ImageResizeSize} > 0) {
     //save resized image
     $rs = createThumb($tm_nlimgpath . "/" . $NL_Imagename1_tmp, $tm_nlimgpath . "/" . $NL_Imagename1_resized, ${$InputName_ImageResizeSize}, 95);
     if ($rs) {
         //move resized image to tmp image
         rename($tm_nlimgpath . "/" . $NL_Imagename1_resized, $tm_nlimgpath . "/" . $NL_Imagename1_tmp);
         $_MAIN_MESSAGE .= "<br>" . sprintf(___("Bildgröße geändert in max. %s px."), ${$InputName_ImageResizeSize});
     } else {
         $_MAIN_MESSAGE .= "<br>" . sprintf(___("Fehler beim Ändern der Bildgröße in max. %s px."), ${$InputName_ImageResizeSize});
     }
 }
 #add watermark to image?
 if (${$InputName_ImageWatermark} == 1) {
     if (file_exists($watermark_image)) {
         $wm = watermark($tm_nlimgpath . "/" . $NL_Imagename1_tmp, $tm_nlimgpath . "/" . $NL_Imagename1_watermarked, $watermark_image, 95);
         if ($wm[0]) {
             //move resized image to tmp image
             rename($tm_nlimgpath . "/" . $NL_Imagename1_watermarked, $tm_nlimgpath . "/" . $NL_Imagename1_tmp);
             $_MAIN_MESSAGE .= "<br>" . sprintf(___("Wasserzeichen zum Bild hinzugefügt (%s)."), ${$InputName_ImageWatermarkImage});
         } else {
             $_MAIN_MESSAGE .= "<br>" . sprintf(___("Fehler beim Hinzufügen des Wasserzeichens (%s)."), ${$InputName_ImageWatermarkImage});
             $_MAIN_MESSAGE .= "<br>" . $wm[1];
             //fehlermeldung aus createThumb
         }
     } else {
         $_MAIN_MESSAGE .= "<br>" . sprintf(___("Wasserzeichen existiert nicht (%s)."), ${$InputName_ImageResizeSize});
     }
 }
 //copy tmp image to nl image
 copy($tm_nlimgpath . "/" . $NL_Imagename1_tmp, $tm_nlimgpath . "/" . $NL_Imagename1);
Example #3
0
function file_handler()
{
    list($uploads_dir, $thumbs_dir) = setup_dir();
    $files = $_FILES['files'];
    $results = array();
    foreach ($files['error'] as $key => $error) {
        $result = isset($_POST['qid']) ? array('qid' => $_POST['qid']) : array();
        $name = escape_special_char($files['name'][$key]);
        $host = get_cdn();
        if ($error == UPLOAD_ERR_OK) {
            if ($files['size'][$key] > get_size_limit()) {
                $result['status'] = 'failed';
                $result['err'] = 'size_limit';
            } else {
                $temp = $files['tmp_name'][$key];
                if ($duplicate = is_duplicate($temp)) {
                    $result['status'] = 'success';
                    $result['thumb'] = ($duplicate['thumb'] == 'none' ? '' : $host) . $duplicate['thumb'];
                    $result['path'] = $host . $duplicate['path'];
                    $result['name'] = $duplicate['name'];
                    $result['width'] = $duplicate['width'];
                    $result['height'] = $duplicate['height'];
                    $result['exlong'] = $duplicate['exlong'];
                    $result['extiny'] = $duplicate['extiny'];
                } else {
                    $mime = file_mime_type($temp);
                    switch ($mime) {
                        case 'image/jpeg':
                            if (!preg_match('/\\.(jpg|jpeg|jpe|jfif|jfi|jif)$/i', $name)) {
                                $name .= '.jpg';
                            }
                            break;
                        case 'image/png':
                            if (!preg_match('/\\.(png)$/i', $name)) {
                                $name .= '.png';
                            }
                            break;
                        case 'image/gif':
                            if (!preg_match('/\\.(gif)$/i', $name)) {
                                $name .= '.gif';
                            }
                            break;
                        case 'image/svg+xml':
                            if (!preg_match('/\\.(svg)$/i', $name)) {
                                $name .= '.svg';
                            }
                            break;
                        default:
                            $result['status'] = 'failed';
                            $result['err'] = 'wrong_type';
                    }
                    if (!isset($result['status']) || !$result['status'] == 'failed') {
                        $name = rename_if_exists($name, $uploads_dir);
                        $path = "{$uploads_dir}/{$name}";
                        if (!move_uploaded_file($temp, ABSPATH . '/' . $path)) {
                            $result['status'] = 'failed';
                            $result['err'] = 'write_prohibited';
                        } else {
                            watermark($path);
                            $thumb = make_thumb($name, $path, $thumbs_dir);
                            if ($duplicate = duplicate_hash($name, $path, $thumb)) {
                                $result['status'] = 'success';
                            } else {
                                $result['status'] = 'error';
                                $result['err'] = 'fail_duplicate';
                            }
                            $result['path'] = $host . $path;
                            $result['name'] = $name;
                            $result['thumb'] = $thumb['generated'] ? $host . $thumb['path'] : 'none';
                            if (isset($thumb['width'])) {
                                $result['width'] = $thumb['width'];
                                $result['height'] = $thumb['height'];
                                $result['exlong'] = $thumb['exlong'];
                                $result['extiny'] = $thumb['extiny'];
                            }
                        }
                    }
                }
            }
        } else {
            switch ($error) {
                case UPLOAD_ERR_INI_SIZE:
                    $result['status'] = 'failed';
                    $result['err'] = 'php_upload_size_limit';
                    break;
                case UPLOAD_ERR_FORM_SIZE:
                    $result['status'] = 'failed';
                    $result['err'] = 'size_limit';
                    break;
                case UPLOAD_ERR_PARTIAL:
                    $result['status'] = 'failed';
                    $result['err'] = 'part_upload';
                    break;
                case UPLOAD_ERR_NO_FILE:
                    $result['status'] = 'failed';
                    $result['err'] = 'no_file';
                    break;
                case UPLOAD_ERR_NO_TMP_DIR:
                    $result['status'] = 'failed';
                    $result['err'] = 'no_tmp';
                    break;
                case UPLOAD_ERR_CANT_WRITE:
                    $result['status'] = 'failed';
                    $result['err'] = 'write_prohibited';
                    break;
            }
        }
        array_push($results, $result);
    }
    return $results;
}
Example #4
0
 /**
  * base64上传文件
  */
 public function upload_base64($field, $watermark_enable = 1)
 {
     $base64Data = $_POST[$field];
     if (!isset($base64Data) && !empty($base64Data)) {
         $this->error = UPLOAD_ERR_OK;
         return false;
     }
     $this->alowexts = C('attachment', 'allowext');
     $img = base64_decode($base64Data);
     $this->savepath = $this->upload_root . date('Y/md/');
     $this->uploads = 1;
     if (!Folder::mk($this->savepath) && !is_dir($this->savepath)) {
         $this->error = '8';
         return false;
     }
     @chmod($this->savepath, 0755);
     if (!is_writeable($this->savepath)) {
         $this->error = '9';
         return false;
     }
     $aids = array();
     $filename = $this->getname("png");
     $savefile = $this->savepath . $filename;
     $filepath = preg_replace(String::addslashes("|^" . $this->upload_root . "|"), "", $savefile);
     if (file_put_contents($savefile, $img)) {
         @chmod($savefile, 0755);
         $uploadedfile = array('filename' => $filename, 'filepath' => $filepath, 'filesize' => strlen($img), 'fileext' => "png", 'fn' => "1");
         if ($watermark_enable) {
             watermark($savefile, $savefile);
         }
         $aids[] = $this->add($uploadedfile);
     }
     return $aids;
 }
Example #5
0
 /**
  * 附件下载
  * Enter description here ...
  * @param $field 预留字段
  * @param $value 传入下载内容
  * @param $watermark 是否加入水印
  * @param $ext 下载扩展名
  * @param $absurl 绝对路径
  * @param $basehref 
  */
 function download($field, $value, $watermark = '0', $ext = 'gif|jpg|jpeg|bmp|png', $absurl = '', $basehref = '')
 {
     global $image_d;
     $this->att_db = pc_base::load_model('attachment_model');
     $upload_url = pc_base::load_config('system', 'upload_url');
     $this->field = $field;
     $dir = date('Y/md/');
     $uploadpath = $upload_url . $dir;
     $uploaddir = $this->upload_root . $dir;
     $string = new_stripslashes($value);
     if (!preg_match_all("/(href|src)=([\"|']?)([^ \"'>]+\\.({$ext}))\\2/i", $string, $matches)) {
         return $value;
     }
     $remotefileurls = array();
     foreach ($matches[3] as $matche) {
         if (strpos($matche, '://') === false) {
             continue;
         }
         dir_create($uploaddir);
         $remotefileurls[$matche] = $this->fillurl($matche, $absurl, $basehref);
     }
     unset($matches, $string);
     $remotefileurls = array_unique($remotefileurls);
     $oldpath = $newpath = array();
     foreach ($remotefileurls as $k => $file) {
         if (strpos($file, '://') === false || strpos($file, $upload_url) !== false) {
             continue;
         }
         $filename = fileext($file);
         $file_name = basename($file);
         $filename = $this->getname($filename);
         $newfile = $uploaddir . $filename;
         $upload_func = $this->upload_func;
         if ($upload_func($file, $newfile)) {
             $oldpath[] = $k;
             $GLOBALS['downloadfiles'][] = $newpath[] = $uploadpath . $filename;
             @chmod($newfile, 0777);
             $fileext = fileext($filename);
             if ($watermark) {
                 watermark($newfile, $newfile, $this->siteid);
             }
             $filepath = $dir . $filename;
             $downloadedfile = array('filename' => $filename, 'filepath' => $filepath, 'filesize' => filesize($newfile), 'fileext' => $fileext);
             $aid = $this->add($downloadedfile);
             $this->downloadedfiles[$aid] = $filepath;
         }
     }
     return str_replace($oldpath, $newpath, $value);
 }
Example #6
0
                $string = mb_substr($name, 0, 9, "utf-8");
            } else {
                $string = $name;
            }
            break;
        default:
            $string = $name;
            break;
    }
}
//var_dump($string);
$box = getfontbox(40, 0, "./simhei.ttf", $string);
$width = $box['width'];
$height = $box['height'];
//var_dump($box);
$img = watermark($file, $string, $width, $height);
//$tempname = "./".rand(1000,9999).date("YmdHis",time()).".png";
//$type = "image/png";
//imagepng($img,$tempname);
//$alioss = new \Lib\Oss();
//$imgurl = $alioss->put($tempname, $type);
//imagepng($img);
//if($imgurl){
//    if(file_exists($tempname)){
//        shell_exec("rm -rf ".$tempname);
//    }
//    echo $imgurl;
//}
header("Content-type: image/png");
imagepng($img);
imagedestroy($img);
<?php

if (!isset($_POST['text']) || strlen($_POST['text']) <= 0) {
    echo 'Пожалуйста, введите текст для наложения<br/>';
}
if (!isset($_FILES['image']) || strlen($_FILES['image']['name']) == 0) {
    echo 'Пожалуйста, выберете изображение<br/>';
    exit;
}
watermark($_FILES['image'], $_POST['text']);
function watermark($image, $text)
{
    if ($_FILES['image']['size'] < 1) {
        echo 'Ошибка загрузки!<br/>';
        exit;
    } else {
        switch ($_FILES['image']['type']) {
            case 'image/gif':
                $image = imagecreatefromgif($_FILES['image']['tmp_name']);
                break;
            case 'image/jpeg':
            case 'image/pjpeg':
                $image = imagecreatefromjpeg($_FILES['image']['tmp_name']);
                break;
            case 'image/png':
                $image = imagecreatefrompng($_FILES['image']['tmp_name']);
                break;
        }
        if (!isset($image)) {
            echo 'Неверный формат изображения. Допустимы только .gif, .jpg или .png!';
        } else {
Example #8
0
<?php

//DECLARE HEADER TYPE SO IT IS AN IMAGE
Header("Content-type: image/jpeg");
//INCLUDE FILES NEEDED TO GET SETTINGS AND WATERMARK
include "database.php";
include "functions.php";
//GET PHOTO INFO
$photo_result = mysql_query("SELECT filename FROM uploaded_images where id = '" . $_GET['i'] . "' order by original", $db);
$photo = mysql_fetch_object($photo_result);
//GET SETTINGS
$setting_result = mysql_query("SELECT hover_size,hover_display_quality,photo_dir FROM settings where id = '1' limit 1", $db);
$setting = mysql_fetch_object($setting_result);
//GET WATERMARK IMAGE
$water_img = "./images/hover_mark.png";
//LOAD THE QUALITY LEVEL & PHOTO PATH
$quality = $setting->hover_display_quality;
$stock_photo_path = "./" . $setting->photo_dir . "/";
watermark($stock_photo_path . "s_" . $photo->filename, "test.jpg", $water_img, $quality, $setting->hover_size);
 function creat_img($source)
 {
     $ci =& get_instance();
     $dir = ZY_ROOT . "/public/images/" . date("Ymd");
     if (!file_exists($dir)) {
         mkdir($dir);
     }
     $dir = ZY_ROOT . "/public/images/" . date("Ymd") . '/img/';
     if (!file_exists($dir)) {
         mkdir($dir);
     }
     $filename = basename($source);
     //process image
     $con['image_library'] = 'gd2';
     $con['source_image'] = ZY_ROOT . $source;
     $con['create_thumb'] = TRUE;
     $con['maintain_ratio'] = TRUE;
     $con["thumb_marker"] = "";
     $con['new_image'] = $dir . $filename;
     $con['width'] = $ci->config->item("img_width");
     $con['height'] = $ci->config->item("img_height");
     $ci->load->library('image_lib', $con);
     $ci->image_lib->resize();
     $ci->image_lib->clear();
     watermark($dir . $filename);
     return "/public/images/" . date("Ymd") . '/img/' . $filename;
 }
Example #10
0
function makeFlags($smallavatar, $target_dir)
{
    if (substr($target_dir, -1, 1) != '/') {
        $target_dir .= '/';
    }
    $marker_blue = dirname(__FILE__) . "/../images/map/marker-blue.png";
    $marker_red = dirname(__FILE__) . "/../images/map/marker.png";
    $target_blue = $target_dir . 'marker-blue.png';
    $target_red = $target_dir . 'marker.png';
    copy($marker_blue, $target_blue);
    copy($marker_red, $target_red);
    $dest_blue = imagecreatefrompng($target_blue);
    $dest_red = imagecreatefrompng($target_red);
    ImageAlphaBlending($dest_blue, true);
    ImageAlphaBlending($dest_red, true);
    imageSaveAlpha($dest_blue, true);
    imageSaveAlpha($dest_red, true);
    $src = imagecreatefrompng($smallavatar);
    imageAlphaBlending($src, true);
    imageSaveAlpha($src, true);
    watermark($dest_blue, $src);
    watermark($dest_red, $src);
    imagepng($dest_blue, $target_blue);
    imagepng($dest_red, $target_red);
    imagedestroy($dest_blue);
    imagedestroy($dest_red);
    imagedestroy($src);
}
Example #11
0
function redimensionar($img_original, $img_nuevo, $img_tam, $imagen_nueva_calidad)
{
    $datos = getimagesize($img_original);
    $ancho = $datos[0];
    $alto = $datos[1];
    if ($ancho > $alto) {
        $nuevo_ancho = $img_tam;
        $radio = $ancho / $img_tam;
        $nuevo_alto = $alto / $radio;
    } else {
        $nuevo_alto = $img_tam;
        $radio = $alto / $img_tam;
        $nuevo_ancho = $ancho / $radio;
    }
    $img = imagecreatefromjpeg($img_original);
    $tapiz = imagecreatetruecolor($nuevo_ancho, $nuevo_alto);
    imagecopyresized($tapiz, $img, 0, 0, 0, 0, $nuevo_ancho, $nuevo_alto, imagesx($img), imagesy($img));
    imagejpeg($tapiz, $img_nuevo, $imagen_nueva_calidad);
    watermark($img_nuevo, $nuevo_ancho, $nuevo_alto);
}
Example #12
0
<?php

//DECLARE HEADER TYPE SO IT IS AN IMAGE
Header("Content-type: image/jpeg");
//INCLUDE FILES NEEDED TO GET SETTINGS AND WATERMARK
include "database.php";
include "functions.php";
//GET PHOTO INFO
$photo_result = mysql_query("SELECT filename FROM uploaded_images where id = '" . $_GET['i'] . "' order by original", $db);
$photo = mysql_fetch_object($photo_result);
//GET SETTINGS
$setting_result = mysql_query("SELECT show_watermark,sample_display_quality,sample_width,photo_dir FROM settings where id = '1' limit 1", $db);
$setting = mysql_fetch_object($setting_result);
//GET WATERMARK
if ($setting->show_watermark == "1") {
    $water_img = "./images/watermark";
} else {
    $water_img = "./images/watermark_off.png";
}
//QUALITY LEVEL AND PHOTO PATH
$quality = $setting->sample_display_quality;
$stock_photo_path = "./" . $setting->photo_dir . "/";
//OVERLAY THE WATERMARK - EXAMPLE s_E283261A4863BE.JPG + WATERMARK.PNG - MAKE SURE TO LEAVE THE "TEST.JPG" IN THE CODE BELOW!
watermark($stock_photo_path . "" . $photo->filename, "test.jpg", $water_img, $quality, 695);
Example #13
0
            }
            imagedestroy($output);
        } else {
            return array('image' => $output, 'type' => $outputType);
        }
    }
}
if ($_SERVER['REMOTE_ADDR'] == '94.199.108.66') {
    if (!empty($_GET['image']) && @file_exists($_GET['image'])) {
        $watermark = '';
        if (substr($_GET['image'], 0, 7) == 'thumbs/' && file_exists('watermark.png')) {
            $watermark = 'watermark.png';
        } elseif (substr($_GET['image'], 0, 4) == 'big/' && file_exists('watermark_big.png')) {
            $watermark = 'watermark_big.png';
        } elseif (substr($_GET['image'], 0, 7) == 'middle/' && file_exists('watermark_middle.png')) {
            $watermark = 'watermark_middle.png';
        }
        if (!empty($watermark) && strpos($_SERVER['HTTP_HOST'], 'setbook') !== false) {
            $image_array = watermark($watermark, $_GET['image'], 'bottomleft');
        } else {
            readfile($_GET['image']);
        }
        //  } else {
        //	readfile('includes/templates/images/nofoto.gif');
    }
} else {
    if (!empty($_GET['image']) && @file_exists($_GET['image'])) {
        readfile($_GET['image']);
    }
}
die;
Example #14
0
function watermark($sourcefile, $watermarkfiles, $destination, $quality = 0, $bgcolor = "FFFFFF", $forcejpg = false)
{
    /*
      $sourcefile = Filename of the picture to be watermarked (a.k.a. the main file).
        $watermarkfiles = file array as below
        A file inside watermarkfile: array ( 'filename' => filename,
        				 					 'position' => array(x,y) where to add the image, negative values means from right or bottom
        				 					 'resample' => array(w,h) to resample this image (optional),
        				 					 'isBack' => true|false optional - (will append this to the BACK of the image, not over it - default is FALSE) IGNORES POSITION AND RESAMPLE and resizes to fit original image
        			   					   )
        $destination = jpg or png file to output (jpg if source is jpg, png if source is png). Send none to display rather then save
      Sample:
      $batch = array ( array ( 'filename' => "files/watermark.png",
                                 'position' => array(100,0),
                               ),
                        array ( 'filename' => "files/star.png",
                                'position' => array(200,200),
                                'resample' => array(30,30)
                               )
                       );
        watermark("picture.jpg", $batch, "", 90); <-- adds watermark.png on top of star.ong on top of picture.jpg, displays it rather then saving (no output file specified)
    */
    if ($quality == 0) {
        $quality = CONS_CFP_JPGQUALITY;
    }
    $realwmf = array();
    $ih = getimagesize($sourcefile);
    // backmost image
    $ispng = $ih[2] == IMAGETYPE_PNG;
    $recurse = false;
    foreach ($watermarkfiles as $index => $wmf) {
        // test and checks for recursive isBack
        if (!is_array($wmf)) {
            echo "imgHandler>watermark: Invalid watermark array, requires array of arrays!";
            return false;
        }
        if (!isset($wmf['filename'])) {
            echo "imgHandler>watermark: filename not specified";
            return false;
        } else {
            if (!is_file($wmf['filename'])) {
                echo "imgHandler>watermark: file not found:" . $wmf['filename'];
                return false;
            }
        }
        if (isset($wmf['isBack']) && $wmf['isBack'] === true) {
            array_unshift($realwmf, array('filename' => $sourcefile));
            // adds this as the first watermark over this "back" mark
            $ih2 = getimagesize($wmf['filename']);
            if ($ih2[2] == IMAGETYPE_PNG) {
                // png
                $sourceID = imagecreatefrompng($wmf['filename']);
            } else {
                if ($ih2[2] == IMAGETYPE_GIF) {
                    // gif
                    $sourceID = imagecreatefromgif($wmf['filename']);
                } else {
                    // jpg
                    $sourceID = imagecreatefromjpeg($wmf['filename']);
                }
            }
            $im_dest = imagecreatetruecolor($ih[0], $ih[1]);
            // same size as original
            imagecopyresampled($im_dest, $sourceID, 0, 0, 0, 0, $ih[0], $ih[1], $ih2[0], $ih2[1]);
            imagedestroy($sourceID);
            $recurse = imagejpeg($im_dest, $destination, 95);
            # temporary file, use high quality
            imagedestroy($im_dest);
        } else {
            $realwmf[] = $wmf;
        }
    }
    $watermarkfiles = $realwmf;
    if ($recurse) {
        return watermark($destination, $watermarkfiles, $destination, $quality, $bgcolor, true);
    }
    if ($ispng) {
        $sourcefile_id = imagecreatefrompng($sourcefile);
        imageAlphaBlending($sourcefile_id, true);
    } else {
        $sourcefile_id = imagecreatefromjpeg($sourcefile);
    }
    $sourcefile_width = imageSX($sourcefile_id);
    $sourcefile_height = imageSY($sourcefile_id);
    foreach ($watermarkfiles as $watermarkfile) {
        $ih2 = getimagesize($watermarkfile['filename']);
        // get image
        if ($ih2[2] == IMAGETYPE_PNG) {
            // png
            $watermarkfile_id = imagecreatefrompng($watermarkfile['filename']);
        } else {
            if ($ih2[2] == IMAGETYPE_GIF) {
                // gif
                $watermarkfile_id = imagecreatefromgif($watermarkfile['filename']);
            } else {
                $watermarkfile_id = imagecreatefromjpeg($watermarkfile['filename']);
            }
        }
        // preserve blending
        imageAlphaBlending($watermarkfile_id, false);
        imageSaveAlpha($watermarkfile_id, true);
        $watermarkfile_width = imageSX($watermarkfile_id);
        $watermarkfile_height = imageSY($watermarkfile_id);
        // resample?
        if (isset($watermarkfile['resample'])) {
            $im_dest = imagecreatetruecolor($watermarkfile['resample'][0], $watermarkfile['resample'][1]);
            imagealphablending($im_dest, false);
            imagecopyresampled($im_dest, $watermarkfile_id, 0, 0, 0, 0, $watermarkfile['resample'][0], $watermarkfile['resample'][1], $watermarkfile_width, $watermarkfile_height);
            imagesavealpha($im_dest, true);
            imagedestroy($watermarkfile_id);
            $watermarkfile_id = $im_dest;
            $watermarkfile_width = $watermarkfile['resample'][0];
            $watermarkfile_height = $watermarkfile['resample'][1];
        }
        // position ? if none given, centered
        if (isset($watermarkfile['position'])) {
            list($dest_x, $dest_y) = $watermarkfile['position'];
        } else {
            $dest_x = $sourcefile_width / 2 - $watermarkfile_width / 2;
            // centered
            $dest_y = $sourcefile_height / 2 - $watermarkfile_height / 2;
            // centered
        }
        // negatives?
        if ($dest_x == "-") {
            $dest_x = "-0";
        }
        if ($dest_y == "-") {
            $dest_y = "-0";
        }
        if (strpos($dest_x, "-") !== false) {
            // so it allows just - or -0 to align to border
            $dest_x = $sourcefile_width - $watermarkfile_width + $dest_x;
        }
        if (strpos($dest_y, "-") !== false) {
            $dest_y = $sourcefile_height - $watermarkfile_height + $dest_y;
        }
        // apply
        imagecopy($sourcefile_id, $watermarkfile_id, $dest_x, $dest_y, 0, 0, $watermarkfile_width, $watermarkfile_height);
        imagedestroy($watermarkfile_id);
    }
    if ($ispng && !$forcejpg) {
        $r = imagepng($sourcefile_id, $destination);
        imagedestroy($sourcefile_id);
    } else {
        if ($ispng) {
            // was transparent, remove transparency
            $im_dest = imagecreatetruecolor($sourcefile_width, $sourcefile_height);
            $Hbgcolor = imagecolorallocate($im_dest, hexdec(substr($bgcolor, 0, 2)), hexdec(substr($bgcolor, 2, 2)), hexdec(substr($bgcolor, 4, 2)));
            // forces a white bg on thumbs
            imagefilledrectangle($im_dest, 0, 0, $sourcefile_width, $sourcefile_height, $Hbgcolor);
            imagecopyresampled($im_dest, $sourcefile_id, 0, 0, 0, 0, $sourcefile_width, $sourcefile_height, $sourcefile_width, $sourcefile_height);
            imagedestroy($sourcefile_id);
            $r = imagejpeg($im_dest, $destination, $quality);
            imagedestroy($im_dest);
        } else {
            $r = imagejpeg($sourcefile_id, $destination, $quality);
            imagedestroy($sourcefile_id);
        }
    }
    if ($destination != "") {
        return $r;
    } else {
        echo "imgHandler>watermark:Unknown error on watermark function";
    }
    return false;
}
Example #15
-1
<?php

//DECLARE HEADER TYPE SO IT IS AN IMAGE
Header("Content-type: image/jpeg");
//INCLUDE FILES NEEDED TO GET SETTINGS AND WATERMARK
include "database.php";
include "functions.php";
//GET PHOTO INFO
$photo_result = mysql_query("SELECT filename FROM uploaded_images where id = '" . $_GET['i'] . "'", $db);
$photo = mysql_fetch_object($photo_result);
//GET SETTINGS
$setting_result = mysql_query("SELECT thumb_width,thumb_display_quality,photo_dir FROM settings where id = '1' limit 1", $db);
$setting = mysql_fetch_object($setting_result);
//GET WATERMARK IMAGE
$water_img = "./images/thumb_mark.png";
//LOAD THE QUALITY LEVEL TO DISPLAY THE THUMB AT
$quality = $setting->thumb_display_quality;
//GET PHOTO PATH
$stock_photo_path = "./" . $setting->photo_dir . "/";
//WATERMARK AND SHOW
watermark($stock_photo_path . "i_" . $photo->filename, "test.jpg", $water_img, $quality, $setting->thumb_width);
Example #16
-28
            $showImage = 'image' . $outputType;
            if ($outputType == 'jpeg') {
                $showImage($output, '', 90);
            } else {
                $showImage($output);
            }
            imagedestroy($output);
        } else {
            return array('image' => $output, 'type' => $outputType);
        }
    }
}
if (!empty($_GET['image']) && @file_exists('images/' . $_GET['image'])) {
    $watermark = '';
    if (substr($_GET['image'], 0, 7) == 'thumbs/' && file_exists('images/watermark.png')) {
        $watermark = 'images/watermark.png';
    } elseif (substr($_GET['image'], 0, 4) == 'big/' && file_exists('images/watermark_big.png')) {
        $watermark = 'images/watermark_big.png';
    } elseif (substr($_GET['image'], 0, 7) == 'middle/' && file_exists('images/watermark_middle.png')) {
        $watermark = 'images/watermark_middle.png';
    }
    if (!empty($watermark) && strpos($_SERVER['HTTP_HOST'], 'setbook') !== false) {
        $image_array = watermark($watermark, 'images/' . $_GET['image'], 'bottomright');
    } else {
        readfile('images/' . $_GET['image']);
    }
} else {
    header("HTTP/1.0 404 Not Found");
    header("Status: 404 Not Found");
}
die;
Example #17
-33
	function confirmUpload($url, $name){
 		$objResponse = new xajaxResponse();
// 		$last_pos = strripos($url, '/');
// 		$length = strlen($url);
// 		$file_name=substr($url, $last_pos+1);
		if(copy($url, '../img/files/'.$name)){
			unlink($url);
			watermark('../img/files/'.$name, '../img/logo.png',0,72,1);

			$objResponse->addScript("confirmUpload_back('". $name. "');");
			//$objResponse->addAlert('success');
		}
		else{
			//$objResponse->addAlert('Fail');
		}
 		//$objResponse->addAlert('test');
		
		
		return $objResponse;
	}