/usr/share/doc/ruby-rmagick/examples/describe.rb is in ruby-rmagick-doc 2.16.0-4.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # Purpose: Demonstrate getting information from the image attributes.
# Usage: describe.rb filename1 [filename2...]
# Notes: The output is similar to ImageMagick's identify command.
require 'rmagick'
puts <<END_INFO
This example shows how to extract attributes from an image.
END_INFO
if ARGV.length == 0
puts 'Specify one or more image filenames as arguments.'
exit
end
ARGV.each do |file|
puts file
img = Magick::Image.read(file).first
puts " Format: #{img.format}"
puts " Geometry: #{img.columns}x#{img.rows}"
puts ' Class: ' + case img.class_type
when Magick::DirectClass
'DirectClass'
when Magick::PseudoClass
'PseudoClass'
end
puts " Depth: #{img.depth} bits-per-pixel"
puts " Colors: #{img.number_colors}"
puts " Filesize: #{img.filesize}"
puts " Resolution: #{img.x_resolution.to_i}x#{img.y_resolution.to_i} "\
"pixels/#{img.units == Magick::PixelsPerInchResolution ?
'inch' : 'centimeter'}"
if img.properties.length > 0
puts ' Properties:'
img.properties do |name,value|
puts %Q| #{name} = "#{value}"|
end
end
end
|