Created
May 7, 2015 21:56
-
-
Save icarofreire/957eb6a83d10f61c88d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Inserir marca D'agua em uma imagem JPG; | |
* | |
* Para exibir a foto no site, vc colocará a seguinte definição abaixo no | |
* src da tag img do html: | |
* marca_d.php?ft=<arquivo da foto em jpg>&lg=<arquivo da logomarca em jpg> | |
* | |
* Exemplo: | |
* <img src='marca_d.php?ft=foto.jpg&lg=logo.jpeg' alt=''> | |
* | |
* OBS: As imagens deverão estar no formato JPG. | |
* | |
* */ | |
function marca_d($foto, $logo) | |
{ | |
$im = imagecreatefromjpeg($foto); | |
$stamp = imagecreatefromjpeg($logo); | |
$margem = 20; //10; | |
$margem_direita = $margem; | |
$margem_baixo = $margem; | |
$sx = imagesx($stamp); | |
$sy = imagesy($stamp); | |
// insere a imagem na diagonal inferior direita. | |
//imagecopy($im, $stamp, imagesx($im) - $sx - $margem_direita, imagesy($im) - $sy - $margem_baixo, 0, 0, imagesx($stamp), imagesy($stamp)); | |
imagecopymerge($im, $stamp, imagesx($im) - $sx - $margem_direita, imagesy($im) - $sy - $margem_baixo, 0, 0, imagesx($stamp), imagesy($stamp), 50); | |
header('Content-type: image/jpeg'); | |
imagejpeg($im); | |
imagedestroy($im); | |
} | |
/* ________________________________________________________ */ | |
if ( | |
(isset($_GET['ft']) && (!empty($_GET['ft']))) && | |
(isset($_GET['lg']) && (!empty($_GET['lg']))) | |
) { | |
$foto = $_GET['ft']; | |
$logo = $_GET['lg']; | |
marca_d($foto, $logo); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment