I used resize_to_fill to a size of [1,1], thus reducing the image to one pixel containing what is basically the middle color of the whole image (assuming the image doesn't have much difference between the height and width, of course). Now I am trying to get the color of this single pixel in hexadecimal format.
In the terminal window, I can run the convert command as follows:
convert image.png txt: # ImageMagick pixel enumeration: 1,1,255,rgb 0,0: (154,135,116) #9A8774 rgb(154,135,116)
However, I do not know how I can run this command from the application during the before_save section of the model to which the image belongs. The image is loaded and attached using the carrier.
So far, I got the image:
image = MiniMagick::Image.read(File.open(self.image.path))
But I'm not quite sure how to get out of here.
source share