Transparency problems with PNG Image to ImgPlus

I can’t seem to pass .png files through the PNG Image to ImgPlus node and retain the background transparency and foreground colors… My goal is to use the Merger node to layer a transparent png images over top of a solid background color png.

The only way that I have been able to keep the color of the top layer png images (with transparent background), is if I set the Replace the Alpha Value constant to 255. If I leave it unchecked (as it seems like it should be…) then it strips the color from the images.

It seems like no matter what setting I use, all of the color and transparency is stripped out when it gets to the Merger Node. Any ideas?

I tried this a ton of ways including trying to use the “External Tool” node to execute ImageMagick via command line…

In the end it was just too much easier to use a simple tool for image conversion and resizing… This is a side project that will likely only require an annual update. I ended up going with a free software called FastStone Photo Resizer to do batch conversions / resizes to easily flatten thousands of images and scale / size them to my needs.


Hi @iCFO,

indeed image manipulation in KNIME can be a fun challenge - the image processing extension is targeted more towards scientific purposes and less towards image manipulation tasks (hence image processing and not graphics editing)

Still it is doable :slight_smile:

The first box is to read in the alpha-png as a ImgPlus - the cell-type that image processing understands. Then I stripped the alpha channel, and joined in the image I want to have as a “background” (single color images for now; they need to have the same dimensions). Lastly, I used the “Image Calculator” to actually do the overlaying, based on the RGB and Alpha Values. This is the resulting table where the “overlaid” column can be saved as a png:

I’m not really sure whether that helps you, but I enjoyed the challenge :wink: For practical purposes it should be much (much) more convenient to do it with a proper graphics editor (Gimp, FastStine Photo Resizer …). Particularly ImageMagick comes to my mind, where I could imagine it is well accessible via the External Tool node. Still, here is the workflow:

Of course: hit me with questions if you are interested!



Amazing solution @LukasS!

This is beyond awesome! With a few minutes of tweaking I have it cranking out thousands of renamed images in an organized folder structure with a uniform background (and a summary of the new / updated images). I thought for sure that this would require the External Tool node and something like ImageMagick through the command line. (I was too unfamiliar with ImageMagick command line to troubleshoot my errors on that approach…)

This is a very creative and much cleaner solution! Thanks again!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.