Php ile resimlere 'Filigran' Ekle

5 Cevap php

Kullanıcıların resim yüklemek olabilecek bir web sitesi var ...

Ben onlar yüklendikten sonra görüntülere benim logosu (filigran) eklemeniz gerekir.

Ben bu yüzden nasıl yapabilirim?

Ve filigran görünür olacak bir köşede olması önemlidir, örneğin, ben anında bir filigran oluşturur ve ana görüntünün arka plan yani "aynı renk" her yerde işareti koyar web gördük Ne demek istediğimi biliyorum filigran uzatıyor.

Anybody have a good tutorial or article about this? Or know of any function in php which I would need to find the position of the watermark?

5 Cevap

A good example PHP kılavuzda:

// Load the stamp and the photo to apply the watermark to
$stamp = imagecreatefrompng('stamp.png');
$im = imagecreatefromjpeg('photo.jpeg');

// Set the margins for the stamp and get the height/width of the stamp image
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp);
$sy = imagesy($stamp);

// Copy the stamp image onto our photo using the margin offsets and the photo 
// width to calculate positioning of the stamp. 
imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));

// Output and free memory
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);

Good Example of watermark image and positioned at the center

<?php
// Load the stamp and the photo to apply the watermark to
$stamp = imagecreatefrompng('stampimg.png');
$im = imagecreatefrompng('mainimage.png');

// Set the margins for the stamp and get the height/width of the stamp image
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp);
$sy = imagesy($stamp);

$imgx = imagesx($im);
$imgy = imagesy($im);
$centerX=round($imgx/2);
$centerY=round($imgy/2);

// Copy the stamp image onto our photo using the margin offsets and the photo 
// width to calculate positioning of the stamp. 
imagecopy($im, $stamp, $centerX, $centerY, 0, 0, imagesx($stamp), imagesy($stamp));

// Output and free memory
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>

. Htaccess ile dinamically bir filigran eklemek çok daha iyi bir çözüm bulundu, sen öğretici burada bulabilirsiniz:

Add watermark to images through htaccess

Özel. Htaccess dosyası, watermark.php scrypt, ve watermark.png görüntüyü yükledikten sonra, tüm klasördeki görüntüleri ve alt klasörleri, ancak yine de sunucu orijinal dosyayı tutacak, filigran gösterecektir.

Birisi bana yardımcı olduğu aynı Umut olur.

Bu, GD veya ImageMagick gibi bir görüntü işleme kütüphanesi kullanılarak yapılabilir. İşte GD kullanarak bunu yapmak için bir yol açıklayan bir öğretici olduğunu:

http://articles.sitepoint.com/article/watermark-images-php

ImageMagick Bunun için iyi çalışır. Bunu daha önce yaptık. Tüm iş olsa, bir ağrı biraz. Eğer fantezi karıştırma modları ve benzeri istiyorum özellikle.