Reputation: 39
how can I add to a .dds file (without alpha), an alpha channel? The source for the alpha data, is a 8bit gray tiff. I tried gdal_merge but it seems that adds transparency to the rgb and not a new alpha channel. Thank you!
Upvotes: 1
Views: 1006
Reputation: 207748
You can put a greyscale image into the alpha channel of an image using ImageMagick, which is installed on most Linux distros and is available for macOS and Windows, like this:
magick input.dds greyscale.tif -compose copyopacity -composite result.dds
The input images could equally be TIF, GIF, or JPEG and the output image could be PNG or anything that supports transparency.
Here's an example. Create a magenta input image:
magick -size 600x400 xc:magenta input.dds
Make a black-white gradient greyscale TIF:
magick -size 600x400 gradient: alpha.tif
Use greyscale gradient as alpha layer in magenta original:
magick input.dds alpha.tif -compose copyalpha -composite result.dds
If you are using v6, or older, of ImageMagick, replace all occurrences of magick
in my command lines above with convert
.
Upvotes: 1