tobius/imagecolors

Allow Mask/pngs

Closed this issue · 0 comments

I would like to be able to run this on an image with a mask: so ignoring the areas marked by the mask when generating the color pallet. Accepting a mask, or alternately accepting pngs with a mask applied would be very helpful.

Here is what I have tried so far:
-I have tried adding the mask to the image, and giving imagecolors.extract the path to the resulting png with the background set to transparent, however then I receive the error 'Histogram extraction failed’. I see that that means no chunks were detected within the histogram, however I cannot figure out why that is the case.

-I have forked the code within my project and am trying to find a way to mask out the background using imagemagick. I have tried passing in both the mask and the image, and using imagemagick to run im(image path).mask(mask path), then running imagecolors like normal on that, however the background is still not ignored. I still end up extracting colors from the background. Upon further research i discovered imagemagick.mask simply write-protects those pixels, and so doesn’t prevent imagemagic from reading them in the histogram.

-I see that in the non-node version of image graphics the correct way to apply a mask is using composite, and have found this command: convert image.jpeg mask.jpeg -alpha off -compose copy_opacity -composite result.png. I see that in the npm gm you should be able to add custom commands from imagegraphics, however I have not yet been able to get this command to work succesfully.

Any work around suggestions would be appreciated, Thanks!
Vicki