@Lokosit; Bilgisayarınızda veya sunucunuzda
Composer kurulu değilse
şu yazımı okumanızı tavsiye ediyorum.
composer.json;
{
"minimum-stability": "dev",
"require": {
"imsaintx/utils": "dev-master",
"intervention/image": "dev-master",
"intervention/imagecache": "dev-master"
}
}watermark.php;
<?php
/**
* WM -> WaterMark
*
* @author: Ogün Karakuş (saintx) <ogunkarakus@superposta.com>
*/
# Dosyanın çalıştırıldığı dizin
define("WM_ABS_PATH", str_replace("\\", "/", dirname(realpath(__FILE__))));
# Resimlerin bulunduğu yol
define("WM_STORAGE_PATH", WM_ABS_PATH."/../storage/uploads/images");
# Watermark dosyası
define("WM_WATERMARK_IMAGE_PATH", WM_ABS_PATH."/../storage/watermark.png");
# Watermark X koordinatı
define("WM_WATERMARK_X_POSITION", 12);
# Watermark Y koordinatı
define("WM_WATERMARK_Y_POSITION", 12);
# Watermark pozisyonu (bottom-right, top-left vs.)
define("WM_WATERMARK_ANCHOR", "bottom-right");
# Watermark atanan resmin önbellekte kalma süresi (saniye cinsinden)
define("WM_WATERMARK_CACHE_TIME", 3600);
if(isset($_GET["file"]) === false || empty($_GET["file"]) === true)
{
# "file" parametresiyle değer gelmediyse işlemi durduralım.
exit("Invalid file.");
}
$file = WM_STORAGE_PATH."/".trim($_GET["file"], "/");
if(file_exists($file) === false)
{
# dosya yoksa işlemi durduralım.
exit("Invalid file.");
}
if(extension_loaded("gd") === false)
{
# GD yüklü değilse durduralım.
exit("PHP GD not installed.");
}
$supported_image_types = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG);
$image_info = getimagesize($file);
$image_type = $image_info[2];
if(in_array($image_type, $supported_image_types) === false)
{
# dosya desteklenmiyor.
exit("Unsupported file type.");
}
unset($image_info, $supported_image_types);
require(WM_ABS_PATH."/vendor/autoload.php");
use \Intervention\Image\Image;
use \Tools\Utils;
$image = Image::cache(function($image) {
global $file;
return $image->make($file)->insert(WM_WATERMARK_IMAGE_PATH, WM_WATERMARK_X_POSITION, WM_WATERMARK_Y_POSITION, WM_WATERMARK_ANCHOR);
}, WM_WATERMARK_CACHE_TIME, true);
Utils::utf8_header($image->mime);
exit($image->response());Uygulamanın çalışır halini
bu bağlantıdan indirebilirsiniz.