Скрипт watermark
Страницы: 1
Скрипт watermark
Здравствуйте, нужна помощь со скриптом наложения watermark. Нужно сделать что бы знак накладывался по центру фотки а не справа внизу подскажите что нужно исправить в коде. Если нужна конкретная доработка готов заплатить.

// накладывает знак на изображение
function watermark($znak, $goto, $name, $orig){

$file_dimensions = @getimagesize($orig);
$file_width = $file_dimensions[0];
$file_height = $file_dimensions[1];

$file_ext = strtolower(str_replace(".", "", strrchr($orig, ".")));



switch($file_ext) {
case "gif":
$name = imagecreatetruecolor($file_width, $file_height);
$img = imagecreatefromgif($orig);
$ramka = imagecreatefrompng($znak);
for($i=0; $i<256; $i++) { imagecolorallocate($name, 255, 255, 255); }
imagecopyresampled($name, $img, 0, 0, 0, 0, $file_width, $file_height, $file_width, $file_height);
imagecopyresampled($name, $ramka, $file_width-350, $file_height-80, 0, 0, 350, 80, 350, 80);
imagejpeg($name, $goto, 100);
ImageDestroy($img);
ImageDestroy($name);
break;
case "jpeg":
case "jpg":
$name = imagecreatetruecolor($file_width, $file_height);
$img = imagecreatefromjpeg($orig);
$ramka = imagecreatefrompng($znak);
for($i=0; $i<256; $i++) { imagecolorallocate($name, 255, 255, 255); }
imagecopyresampled($name, $img, 0, 0, 0, 0, $file_width, $file_height, $file_width, $file_height);
imagecopyresampled($name, $ramka, $file_width-350, $file_height-80, 0, 0, 350, 80, 350, 80);
imagejpeg($name, $goto, 100);
ImageDestroy($img);
ImageDestroy($name);
break;
}
}



function upload_screen_thumb($file, $screen, $file_maxdim) {
$file_type = explode(",", str_replace(" ", "", strtolower("image/jpeg, image/jpg, image/jpe, image/pjpeg, image/pjpg, image/x-jpeg, x-jpg, image/gif, image/x-gif, image/png, image/x-png")));

$file_name = $_FILES[$file]['name'];
$file_type = strtolower($_FILES[$file]['type']);
$file_size = $_FILES[$file]['size'];
$file_tempname = $_FILES[$file]['tmp_name'];
$file_error = $_FILES[$file]['error'];
$file_ext = strtolower(str_replace(".", "", strrchr($file_name, ".")));
$file_dimensions = @getimagesize($file_tempname);
$file_width = $file_dimensions[0];
$file_height = $file_dimensions[1];

if($file_width > $file_height){
$out_height = ($file_width / $file_maxdim);
$width = $file_maxdim;
$height = ($file_height / $out_height);
}else{
$out_width = ($file_height / $file_maxdim);
$height = $file_maxdim;
$width = ($file_width / $out_width);
}

if($width > $height){
$tb = ($file_maxdim - $height) / 2;
$rlb = 0;
}
if($height > $width){
$rlb = ($file_maxdim - $width) / 2;
$tb = 0;
}

switch($file_ext) {
case "gif":

$file = imagecreatetruecolor($file_maxdim, $file_maxdim);
$new = imagecreatefromgif($file_tempname);
$kek=imagecolorallocate($file, 255, 0, 120);
imagefill($file,0,0,$kek);
imagecopyresampled($file, $new, $rlb, $tb, 0, 0, $width, $height, $file_width, $file_height);
imagejpeg($file, $screen, 100);
ImageDestroy($new);
ImageDestroy($file);

//$res = move_uploaded_file($file_tempname, $screen);
//echo $screen;
break;
case "bmp":
$file = imagecreatetruecolor($file_maxdim, $file_maxdim);
$new = imagecreatefrombmp($file_tempname);
$kek=imagecolorallocate($file, 255, 0, 120);
imagefill($file,0,0,$kek);
imagecopyresampled($file, $new, $rlb, $tb, 0, 0, $width, $height, $file_width, $file_height);
imagejpeg($file, $screen, 100);
ImageDestroy($new);
ImageDestroy($file);
break;
case "jpeg":
case "jpg":
$file = imagecreatetruecolor($file_maxdim, $file_maxdim);
$new = imagecreatefromjpeg($file_tempname);
$kek=imagecolorallocate($file, 255, 0, 120);
imagefill($file,0,0,$kek);
imagecopyresampled($file, $new, $rlb, $tb, 0, 0, $width, $height, $file_width, $file_height);
imagejpeg($file, $screen, 100);
ImageDestroy($new);
ImageDestroy($file);
break;
case "png":
$file = imagecreatetruecolor($file_maxdim, $file_maxdim);
imagealphablending($file, false);
imagesavealpha($file,true);
$transparent = imagecolorallocatealpha($file, 255, 0, 120, 127);
$new = imagecreatefrompng($file_tempname);
imagefilledrectangle($file, 0, 0, $file_maxdim, $file_maxdim, $transparent);
imagecopyresampled($file, $new, 0, 0, 0, 0, $file_maxdim, $file_maxdim, $file_width, $file_height);
imagepng($file, $screen);
ImageDestroy($new);
ImageDestroy($file);
break;
}
}
Что неужели никто не знает что нужно исправить в коде что бы знак был по середине фото. Плачу 500 руб. ))
Страницы: 1
Похожие темы:
Читают тему (гостей: 1, пользователей: 0, из них скрытых: 0)
Новые темыОбъявленияСвободное общение
22:12 Яху Скаут и китайцы - есть там вообще жизнь для новичка в 2026? 
21:57 Бесплатное получение бэклинков 
12:25 Бесплатное расширение для Chrome — проверка ссылок прямо на странице 
12:15 Ап выдачи Яндекса 8 апреля - есть движение, но интереснее что творится с AI-ответами Google 
12:13 Хватит ныть про смерть сайтов и нейроответы - почему мы всё еще в деле 
12:11 С чего сейчас проще начать? 
12:09 Биржи ссылок в 2026 - реально ли новичку с одним сайтом поднять копейку? 
23:11 TETChange-Обменник криптовалют 
21:52 [Comcash.io] Анонимный обмен и чистка крипты без AML/KYC 
15:41 Trustpilot Reviews | Подниму рейтинг вашей компании 
15:40 Продвижение YouTube видео в топ поиска | Любой тип контента | Гарантия результата 
15:39 №1 Рассылка / Инвайтинг [TELEGRAM] | Приватный метод 
15:39 Установка|Настройка|Доработка|Наполнение сайтов|Дизайн|3D|Видеомонтаж 
23:36 GoodsMoney.io 
23:28 Точные прогнозы на футбол 
22:16 Ням-ням! - 8 деликатесов, которые когда-то ели только бедные люди 
22:08 Во Франции начали штрафовать за IPTV - до 300-400 евро уже прилетает обычным пользователям 
22:05 Всех с праздником! 
21:56 Сайты Рунета 
21:53 Добро пожаловать в цифровой мир... 
15:42 Список обновленных тем пуст...