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