# File lib/mini_magick.rb, line 101 def import_pixels(blob, columns, rows, depth, map, format="png") # Create an image object with the raw pixel data string: image = create(".dat", validate = false) { |f| f.write(blob) } # Use ImageMagick to convert the raw data file to an image file of the desired format: converted_image_path = image.path[0..-4] + format argument = "-size #{columns}x#{rows} -depth #{depth} #{map}:#{image.path} #{converted_image_path}" cmd = CommandBuilder.new("convert", argument) #Example: convert -size 256x256 -depth 16 gray:blob.dat blob.png image.run(cmd) # Update the image instance with the path of the properly formatted image, and return: image.path = converted_image_path image end