macosterminalpngtransparencysips

Can you remove the alpha channel in a PNG with SIPS?


Trying to stay native in SIPS when removing the alpha channel from images I am familiar with the process in ImageMagick with:

convert -flatten test.png test-white.png

or:

convert test.png -background white -alpha remove test.png

but when I reference the man page on ss4 and Library it tells me that hasAlpa is a boolean read only when I run:

sips -g hasAlpha test.png

Per searching under the tag and with:

there wasn't anything mentioned for removing transparency. Can you remove transparency with SIPS?


Solution

  • Using ImageMagick or GraphicsMagick would be better idea, but if you really want to use SIPS, you could try to remove transparency by converting image to BMP, and then back to PNG again:

    sips -s format bmp input.png --out tmp.bmp
    sips -s format png tmp.bmp --out output.png
    

    Unfortunately you cannot choose background color, transparent parts of image will be replaced with black.