• Downloading from our site will require you to have a paid membership. Upgrade to a Premium Membership from 10$ a month today!

    Dont forget read our Rules! Also anyone caught Sharing this content will be banned. By using this site you are agreeing to our rules so read them. Saying I did not know is simply not an excuse! You have been warned.

dgtupltn95

New Member
Như các bạn đã biết, đây là một thưviện hỗ trợ khá mạnh trong việc xử lý ảnh của PHP. Mình viết TUT này giới thiệu những ví dụ căn bản nhất cho newbie, kiến thức mình có hạn nên nếu sai sót mong các bạn bỏ qua.1. Tạo 1 bức ảnh với PHP
PHP hỗ trợ một số hàm sau
imagecreate
imagecreatefromgd2
imagecreatefromgd2part
imagecreatefromgd
imagecreatefromgif
imagecreatefromjpeg
imagecreatefrompng
imagecreatefromstring
imagecreatefromwbmp
imagecreatefromwebp
imagecreatefromxbm
imagecreatefromxpm
imagecreatetruecolor Khá nhiều nhưng mỗi hàm có cách dùng khác nhau mình nói sau, bây giờ đi vào hàm căn bản nhất là hàm imagecreate().
cách dùng: imagecreate ( $dai ,$rong );
hàm này tạo một bức ảnh trống với chiều dài và chiều rộng quy định.ví dụ nè:
PHP:
header("Content-Type: image/png");
$im = @imagecreate(110, 20) or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 0, 0, 0); //tạo biến màu nền bằng hàm imagecolorallocate()
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,'A Simple Text String', $text_color);
imagepng($im);//tạo một bức ảnh đầy đủ nội dung
imagedestroy($im);
đoạn code trên cho ta 1 ảnh như
 

Facebook Comments

Similar threads

New posts New threads New resources

Back
Top