ImageMagick split transparent PNG, merge jpg, and Alpha Mask

Source: Internet
Author: User
Tags imagemagick

Transparent PNG images occupy a large space and can be split into JPG images and PNG images with Alpha only. Here you use ImageMagick for splitting and merging experiments. ImageMagick version: 6.9.0-q16

Test with Bird.png Pictures:
Split transparent PNG to JPG and alpha-only PNG
1
2
"D:\Program Files\imagemagick-6.9.0-q16\convert.exe" Bird.png-background black-alpha Remove bird.jpg
"D:\Program Files\imagemagick-6.9.0-q16\convert.exe" Bird.png-alpha Extract Bird_alpha_mask.png

Generated bird.jpg Pictures:
Generated bybird_alpha_mask.png Pictures:

Merge jpg and alpha-only PNG as transparent PNG
1
"D:\Program Files\imagemagick-6.9.0-q16\convert.exe" Bird.jpg bird_alpha_mask.png-compose Copyopacity-composite Bird_with_alpha.png

Generated bird_with_alpha.png Pictures:
Batch: Split transparent PNG to JPG and alpha-only PNG
1
2
3
4
5
6
7
@echo  off
set  exevar= "D:\program files\imagemagick-6.9.0-q16\convert.exe"

for  /f " usebackq tokens=* "  % %d in  (' do   (
    %exevar%  "%%d"  -background black -alpha remove "%%~dpnd.jpg "
    %exevar%  "%%d"  -alpha extract  " %%~dpnd_alpha_mask.png "
)

Merge jpg and alpha-only PNG as transparent PNG
1
2
3
4
5
6
@echo  off
set  exevar= "D:\program files\imagemagick-6.9.0-q16\convert.exe"

for  /f " usebackq tokens=* "  % %d in  (' do   (
    %exevar%  "%%d"   "%%~dpnd_alpha_mask.png"  -compose copyopacity -composite  "%%~dpnd_with_ Alpha.png "
)

References:1. Transparent JPEG Images on IOS https://github.com/hollance/TransparentJPEG2. The COCOS2DX uses a JPG graph and an alpha-only PNG image to compose the render HTTP://WWW.CNBLOGS.COM/ELANG/P/4104452.HTML3. ADD an existing alpha data from image to another image http://www.wizards-toolkit.org/discourse-server/viewtopic.php?t= 175294. Converting PNG to Jpeg-black background http://www.imagemagick.org/discourse-server/viewtopic.php?t=24048

ImageMagick split transparent PNG, merge jpg, and Alpha Mask

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.