When we upload images on the site, many of them have the need to add watermarks to the images. Let's give you a detailed explanation
PHP GD Library Implementation of the relevant code examples of Chinese watermark:
- < ? PHP
- $ im = Imagecreatetruecolor (100,100);
- Create a new True color image
- $ White = imagecolorallocate ($im, 255,235,255);
- assigning colors to an image is different from my design knowledge.
I never thought that when painting, I want to assign a color to the specified image ID first
.. This function is often confused with the Imagefill function.
- Imagefill ($im, 0,0, $white);
- Area fill
- $ Black = imagecolorallocate ($im, 250,50,50);
- Assign a color to an image
- Imagerectangle ($im, 5,5,50,50, $black);
- Draw a rectangle
- Header ("Content-type:image/jpeg");
- Sends the header, with imagejpeg to output the image directly in the browser.
- Imagejpeg ($im, ' ImageName ', 100);
- Output a image, naming and quality
- Imagedestroy ($im);
- Releases the memory associated with the image. Image
Is the image identifier returned by the image creation function
- ?>
PHP GD Library Implementation of Chinese watermark code
- < ? PHP
- Header ("Content-type:image/png");
- /* Notify browser, to output image */
- $ im = imagecreate (400, 300);
- /* Define the size of the image */
- $ Gray = imagecolorallocate ($im, 235, 235, 235);
- $ Pink = imagecolorallocate ($im, 255, 128, 255);
- /*
- $ Fontfile = "C:windowsfontssimhei.ttf" ;
- Sorry, this sentence is always adhered to after the submission was lost, do not know what is going on
, the friends who want to test will comment on the test now
- */
- /* $fontfile the path to the font, depending on the operating system, can be
Simhei.ttf (blackbody), Simkai. TTF (in italics),
Simfang. TTF (imitation), SimSun. TTC (Arial & neo-Arial)
GD-Supported Chinese fonts */
- $ Str = Iconv (' GB2312 ', ' UTF-8 ', ' Chinese watermark!!! ');
- /* Convert the gb2312 character set to UTF-8 characters */
- Imagettftext ($im, 30, 0, 50, 140,
$pink, $fontfile, $STR);
- /* Add Chinese watermark */
- Imagepng ($im);
- Imagedestroy ($im);
- ?>
The above is the PHP GD library to achieve the Chinese watermark of the relevant methods summary.
http://www.bkjia.com/PHPjc/446046.html www.bkjia.com true http://www.bkjia.com/PHPjc/446046.html techarticle when we upload images on the site, many of them have the need to add watermarks to the images. Below we will give you a detailed explanation of PHP GD Library implementation of the Chinese watermark code example:? php ...