PHP Cutout Tutorial (Mixed mode + clipping mask)

Source: Internet
Author: User
PS: All the content described in this article requires ImageMagick library support. The general host is supported, but the individual builds the local environment by default does not turn on ImageMagick. The EXEC function can also not be disabled.

1. Keying the image

<?php//Solid Color Bottom cutout $input= "./1.jpg";//the file path to be keyed $ouput= "./1.png";//Storage path $bgcolor= "white";//Background color. Hex color code and RGB (1,1,1) $fuzz = "30000" can be used; The tolerance exec ("Convert $input-fuzz $fuzz-transparent $bgcolor $ouput");//Perform a cutout operation. and enter the specified path

Before the drawing (white bottom):

After cutout (PNG transparent):

2. Feather Edge (auto-detect background)

<?php$a1= ' 1.png '; $A 2= ' 2.png '; $A 3= ' 3.png '; $A 4= ' 4.png '; $A 5= ' 5.png '; $img = ' pending view. jpg '; $im = new Imagick ($img);// 8000 for edge tolerance, modify this value to properly remove unwanted similar noise $im->transparentpaintimage ($im->getimagepixelcolor (0, 0), 0, 8000,0);//Generate PNG format $ Im->setimageformat ("PNG");//Save file name $im->writeimage ("$A 1");//Refine Edge exec ("Convert $A 1-threshold 75% $A 2"); EXEC (" Convert $A 2-fill black-opaque white $A 3 "), EXEC (" Convert $A 3-channel rgba-blur 0x2 $A 4 "); Exec (" Convert $A 1 $A 4-alpha o N-compose copy_opacity-composite $A 5 ");//delete temporary picture unlink ($A 1); unlink ($A 2); unlink ($A 3); unlink ($A 4);

Before drawing

After the drawing is keyed

3. Clipping masks

<?php$img= "1.jpg";//Background $mask= "2.png";//Mongolian territory. PNG format EXEC ("Convert $img $mask-alpha on-compose copy_opacity-composite ouput.png");

Background

Matte Cover

Final effect

4. Mixed mode

<?php//-geometry Size Size overlay to the specified position coordinates//-compose XXXX mixed mode $img= ' 1.jpg ';//Background Graph $img2= ' 2.jpg ';//Map exec (' Convert $img $ Img2-geometry +480+80-compose multiply-composite ouput.jpg ');

Background map


Overlay chart (white bottom)

Final effect


Mixed Mode parameter description: Ps:-compose after the parameter is mixed mode

PHP supports the following mixed-mode parameters

Multiply, screen, BumpMap, Divide, Plus, minus,

Modulusadd, modulussubtract, difference, exclusion, lighten, darken, lightenintensity, darkenintensity,


Mixed Mode in bilingual

1. Normal mode

2. Dissolve (dissolve) mode

3. Darken (darken) mode

4. Multiply (Multiply) mode

5. Color Burn (clolor Burn) mode

6. Linear Burn (Linear Burn) mode

7. Lighten (lighten) mode

8. Color filter (screen) mode

9. Color Dodge (Clolor Dodge) mode

10. Linear Dodge (Linear Dodge) mode

11. Overlay (Overlay) mode

12. Soft Light (Soft) mode

13. Strong Light Mode

14. Brightness (Vivid light) mode

15. Linear Optical (Linear light) mode

16. Point Light (Pin) mode

17. Difference value (diference) mode

18. Exclude (exclusion) mode

19. Hue (hue) mode

20. Saturation (saturation) mode

21. Color Mode

22. Brightness (luminosity) mode

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.