WaterMark - Dong dau anh bang PHP
Qui trình :
- Dùng 1 file hình có nền trong suốt đè lên file hình cần tạo watermark .
- PHP có các hàm để xử lý với ảnh http://vn2.php.net/manual/en/ref.image.php
Code:
<?php $imagesource = "images.jpg"; // dia chi hinh if (!file_exists($imagesource)) die(); $filetype = strtolower(substr($imagesource,strlen($imagesource)-4,4)); if($filetype == ".gif") $image = @imagecreatefromgif($imagesource); if($filetype == ".jpg") $image = @imagecreatefromjpeg($imagesource); if($filetype == ".png") $image = @imagecreatefrompng($imagesource); if (empty($image)) die(); $watermark = @imagecreatefromgif('watermark.gif'); // file watermark $imagewidth = imagesx($image); $imageheight = imagesy($image); $watermarkwidth = imagesx($watermark); $watermarkheight = imagesy($watermark); $startwidth = (($imagewidth - $watermarkwidth)/2); $startheight = (($imageheight - $watermarkheight)/2); imagecopy($image, $watermark, $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight); header("Content-type: image/jpeg"); imagejpeg($image); imagedestroy($image); imagedestroy($watermark); ?>
Nếu cảm thấy tự viết quá khó bãn có thể dùng library có sẵn này để làm cho đơn giản hơn và dễ customize hơn: http://wideimage.sourceforge.net/








ko bit nói gì ! Thanks một cái thoy ! bài viết rất bổ ích !
bao loi nhu the doa
Warning: mysql_query() [function.mysql-query]: Access denied for user ‘ODBC’@'localhost’ (using password: NO) in C:\AppServ\www\diaocvina\online.php on line 6
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\AppServ\www\diaocvina\online.php on line 6
Access denied for user ‘ODBC’@'localhost’ (using password: NO)
Warning: mysql_query() [function.mysql-query]: Access denied for user ‘ODBC’@’localhost’ (using password: NO) in C:\AppServ\www\diaocvina\online.php on line 6
=========> chưa có kết nối với cơ sỡ dữ liệu mà bạn tao ra đó
$server = ‘localhost’;
$username = ‘root’;
$password = ”;
$database = ‘db_online_couter’;// tên databate mà bạn tạo
mysql_connect(”$server”, “$username”, “$password”);
Gửi nhận xét: