-
Imagecolorsforindex ()
- Imagecolorat ()
- Image $ img = imagecreatefromgif ("./images/map.gif ");
-
/**
- * Image sharpening
- * Edit by bbs.it-home.org
- */
- $ Red = imagecolorallocate ($ img, 255, 0, 0 );
-
Imageline ($ img, 0, 0,100,100, $ red );
- Imageellipse ($ img, 200,100,100,100, $ red );
- Imagegif ($ img, "./images/map2.gif ");
- Imagedestroy ($ img );
-
Normal image scaling
- Function thumn ($ background, $ width, $ height, $ newfile ){
- List ($ s_w, $ s_h) = getimagesize ($ background); // Obtain the height and width of the original image.
- If ($ width & ($ s_w <$ s_h )){
- $ Width = ($ height/$ s_h) * $ s_w;
- } Else {
- $ Height = ($ width/$ s_w) * $ s_h;
- }
- $ New = imagecreatetruecolor ($ width, $ height );
- $ Img = imagecreatefromjpeg ($ background );
- Imagecopyresampled ($ new, $ img, 0, 0, 0, 0, $ width, $ height, $ s_w, $ s_h );
- Imagejpeg ($ new, $ newfile );
- Imagedestroy ($ new );
- Imagedestroy ($ img );
- }
- Thumn ("images/hee.jpg", 200,200, "./images/hee3.jpg ");
Gif transparent color processing
-
/**
- * Image cropping
- * Edit by bbs.it-home.org
- */
-
Function cut ($ background, $ cut_x, $ cut_y, $ cut_width, $ cut_height, $ location ){
- $ Back = imagecreatefromjpeg ($ background );
- $ New = imagecreatetruecolor ($ cut_width, $ cut_height );
- Imagecopyresampled ($ new, $ back, 0, 0, $ cut_x, $ cut_y, $ cut_width, $ cut_height, $ cut_width, $ cut_height );
- Imagejpeg ($ new, $ location );
- Imagedestroy ($ new );
- Imagedestroy ($ back );
- }
- Cut ("./images/hee.jpg", 440,140,117,112, "./images/hee5.jpg ");
- ?>
Add text watermarks to images
-
/**
- *
- * Adding a text watermark to an image
- */
-
Function mark_text ($ background, $ text, $ x, $ y ){
- $ Back = imagecreatefromjpeg ($ background );
- $ Color = imagecolorallocate ($ back, 0,255, 0 );
- Imagettftext ($ back, 20, 0, $ x, $ y, $ color, "simkai. ttf", $ text );
- Imagejpeg ($ back, "./images/hee7.jpg ");
- Imagedestroy ($ back );
- }
- Mark_text ("./images/hee.jpg", "PHP", 150,250 );
- // Image watermark
- Function mark_pic ($ background, $ waterpic, $ x, $ y ){
- $ Back = imagecreatefromjpeg ($ background );
- $ Water = imagecreatefromgif ($ waterpic );
- $ W_w = imagesx ($ water );
- $ W_h = imagesy ($ water );
- Imagecopy ($ back, $ water, $ x, $ y, 0, 0, $ w_w, $ w_h );
- Imagejpeg ($ back, "./images/hee8.jpg ");
- Imagedestroy ($ back );
- Imagedestroy ($ water );
- }
- Mark_pic ("./images/hee.jpg", "./images/gaolf.gif", 50,200 );
Image Rotation
-
/**
- * Image rotation
- * Edit by bbs.it-home.org
- */
- $ Back = imagecreatefromjpeg ("./images/hee.jpg ");
-
$ New = imagerotate ($ back, 45, 0 );
- Imagejpeg ($ new, "./images/hee9.jpg ");
- ?>
Horizontal flip vertical flip
-
/**
- * Horizontal flip vertical flip
- * Edit by bbs.it-home.org
- */
- Function turn_y ($ background, $ newfile ){
-
$ Back = imagecreatefromjpeg ($ background );
- $ Width = imagesx ($ back );
- $ Height = imagesy ($ back );
- $ New = imagecreatetruecolor ($ width, $ height );
- For ($ x = 0; $ x <$ width; $ x ++ ){
- Imagecopy ($ new, $ back, $ width-$ X-1, 0, $ x, 0, 1, $ height );
- }
- Imagejpeg ($ new, $ newfile );
- Imagedestroy ($ back );
- Imagedestroy ($ new );
- }
- Function turn_x ($ background, $ newfile ){
- $ Back = imagecreatefromjpeg ($ background );
- $ Width = imagesx ($ back );
- $ Height = imagesy ($ back );
- $ New = imagecreatetruecolor ($ width, $ height );
- For ($ y = 0; $ y <$ height; $ y ++ ){
- Imagecopy ($ new, $ back, 0, $ height-$ Y-1, 0, $ y, $ width, 1 );
- }
- Imagejpeg ($ new, $ newfile );
- Imagedestroy ($ back );
- Imagedestroy ($ new );
- }
- Turn_y ("./images/hee.jpg", "./images/hee11.jpg ");
- Turn_x ("./images/hee.jpg", "./images/hee12.jpg ");
- ?>
|