I have used resize_to_fill down to a [1,1] size thus reducing the image to a single pixel containing what is basically the average color of the entire image (provided the image does not have a huge disparity between height and width, of course). Now I'm attempting to retrieve the color of this single pixel in hex format.
From the terminal window I am able to run the convert command like this:
convert image.png txt:
# ImageMagick pixel enumeration: 1,1,255,rgb
0,0: (154,135,116) #9A8774 rgb(154,135,116)
I am however uncertain of how I could run this command from inside the application during the before_save section of the model that the image belongs to. The image is uploaded and attached using carrierwave
So far I have retrieved the image:
image = MiniMagick::Image.read(File.open(self.image.path))
But I'm not quite certain how to procede from here.