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 sips and with:
there wasn't anything mentioned for removing transparency. Can you remove transparency with SIPS?
You could use the following little script, which uses OSX's built-in PHP which includes GD by default, so you would be staying native and not need ImageMagick or anything extra installed:
So, if I start with this, which is transparent in the middle:
I get this as a result:
I made the canvas background blue so you can see it on StackOverflow's white background, but just change lines 12 & 13 for a white background like this:
I did another answer here in the same vein to overcome another missing feature in
sips
.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:
Unfortunately you cannot choose background color, transparent parts of image will be replaced with black.
Another option, which is much lighter weight than installing the entire ImageMagick might be to use the NetPBM suite:
You can easily install NetPBM using
homebrew
with: