Reputation: 93
By setting a .tiff file "tiff:alpha" tag to either unspecified or unassociated I can have photoshop display it's alpha channel as either a premultiplied transparency or a seperate alpha channel. However if I manually edit an image through photoshop, and I manually add an alpha channel, create transparency in the R/G/B channels and then check "export transparency" during the export process. I can have both the premultiplied channel and the alpha channel. I'm however not able to do this through any processing code using either GIMP or ImageMagick. How would I go about replicating this through script/code and is it even possible?
exec(`gimp -i -d -f -b '(let* ((img (car (file-png-load 1 \"example.png\" \"example.png\")))
(drawable (car (gimp-image-active-drawable img))))
(gimp-image-select-item img 0 drawable)
(plug-in-sel2path 0 img drawable)
(gimp-image-insert-channel img (car (gimp-channel-new-from-component img 5 \"Alpha 1\")) 0 5)
(gimp-image-insert-channel img (car (gimp-channel-new-from-component img 5 \"Transparency\")) 0 6)
(file-tiff-save 1 img drawable \"output.tiff\" \"output.tiff\" 1) (gimp-quit 0))'`, {cwd: `src/images/${r}`, env:process.env}, async (error, stdout, stderr) => {
im.convert([`${appDir}/images/${r}/output.tiff`, "-define",
"tiff:alpha=unspecified", `${appDir}/images/${r}/output2.tiff`], () => {
//script where I save the the output image
})
})
The code above is run in a node.js environment.
A relevant similar question to what i want: How to append an alpha channel to a TIFF (or pdf) with Imagemagick (or imagick php)?
Upvotes: 0
Views: 684
Reputation: 8914
There are two API calls to save a TIFF in Gimp:
(file-tiff-save run-mode image drawable filename raw-filename compression)
and
(file-tiff-save2 run-mode image drawable filename raw-filename compression save-transp-pixels)
As you can see, the only difference between the two is the save-transp-pixels
argument, documented thus:
Keep the color data masked by an alpha channel intact (do not store premultiplied components)
So it's either premultiplied or not premultiplied, but not both.
Upvotes: 1