How do I get the hex value from each pixel in RMagick or Chunky_PNG?
问题 I'm trying to read the value of each pixel as hex (HTML notation) using RMagick or Chunky_PNG e.g. #5DBCD2 . At the moment I have the below which kind of does what I want but I couldn't find the right way to actually read the hex value. I'd prefer to use Chunky_PNG though, thanks! require 'chunky_png' img = ChunkyPNG::Image.from_file("image.png") height = img.dimension.height width = img.dimension.width height.times do |i| width.times do |j| p [ChunkyPNG::Color.r(img[j,i]), ChunkyPNG::Color.g