16 lines
301 B
Ruby
16 lines
301 B
Ruby
|
require 'open3'
|
||
|
|
||
|
class ImageInspector
|
||
|
|
||
|
def get_size(image_path)
|
||
|
o, e, t = Open3.capture3(%(identify -format "%[fx:w]x%[fx:h]" #{image_path}))
|
||
|
|
||
|
if t.exitstatus != 0
|
||
|
raise RuntimeError, "Couldn't inspect image #{image_path}:\n#{o}\n#{e}"
|
||
|
end
|
||
|
|
||
|
o.split('x').map(&:to_i)
|
||
|
end
|
||
|
|
||
|
end
|