Created
October 23, 2012 00:58
-
-
Save anderson-mota/3936007 to your computer and use it in GitHub Desktop.
Marca d´água Ibau
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 | |
if($_POST){ | |
watterMarkUmMais1(); | |
} | |
function watterMarkUmMais1(){ | |
if(isset($_POST['upload'])){ | |
$permitido= array('image/jpg','image/jpeg', 'image/pjpeg'); | |
$img = $_FILES['img']; | |
$tmp = $img['tmp_name']; | |
$name = $img['name']; | |
$type = $img['type']; | |
if(!empty($name) && in_array($type, $permitido)){ | |
watterMarkDownload($tmp); | |
} | |
} | |
} | |
function watterMarkDownload($tmp){ | |
$nome = 'imagem-' . md5(uniqid(rand(),true)) . '.jpg'; | |
$img = imagecreatefromjpeg($tmp); | |
imagecopyresampled($nova,$img,0,0,0,0,$largura,$altura,$largura,$altura); | |
$largura = imagesx($img); | |
$altura = imagesy($img); | |
$nova = imagecreatetruecolor($largura, $altura); | |
imagedestroy($img); | |
$imageMarkPath = bloginfo('template_url') . "/images/UmMais1.png"; | |
$marca = imagecreatefrompng($imageMarkPath); | |
$marcax = imagesx($marca); | |
$marcay = imagesy($marca); | |
$alturaMarca = 15; | |
$larguraMarca = 19; | |
$posicaoAlturaMarca =- 5; | |
$posicaoLarguraMarca =- 5; | |
$localx = ($largura - ($larguraMarca - $posicaoLarguraMarca)); | |
$localy = ($altura - ($alturaMarca - $posicaoAlturaMarca)); | |
imagecopyresampled($nova, $marca, $localx, $localy, 0, 0, $larguraMarca, $alturaMarca, $marcax, $marcay); | |
header("content-type: image/jpeg"); | |
imagejpeg($nova); | |
imagedestroy($nova); | |
} | |
?> | |
<form action="" enctype="multipart/form-data" method="post"> | |
<input type="file" name="img" /> | |
<input type="submit" value="Upload" name="upload"> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment