quru / qis

Dynamic image server for web and print
https://quruimageserver.com
GNU Affero General Public License v3.0
89 stars 7 forks source link

Converting colours to transparency #23

Open qururoland opened 5 years ago

qururoland commented 5 years ago

With the mask it is possible to make an image into a circle (have a white mask with a transparent circle in the middle and overlay it over the image) however the circular image remains on a coloured background. Would it be possible to convert the colour of the background to transparent?

To find the colour in a simple mask: convert mask.gif -format %c -colorspace LAB -colors 5 histogram:info:- | sort -n -r | grep -v "#00000000" will show the 5 most dominant colours in the image. convert image.png -fuzz 20% -transparent "#ff00ffff" transparentimage.png will make all #ff00ffff pixels transparent.

Note that glflib is possibly quicker for getting the colour (need giflib-tools) gifclrmp mask.gif | grep -r "#00000000"`

Note that 2 colour gif palettes for the mask make this much easier. The fuzz option (ie needed for anti-aliasing etc) might need playing with.

It is possible that someone might want to make a colour in the original image transparent rather than in a mask...