Module: RubySpriter::Utils::ImageHelper

Defined in:
lib/ruby_spriter/utils/image_helper.rb

Class Method Summary collapse

Class Method Details

.get_dimensions(image_path) ⇒ Object

Raises:



4
5
6
7
8
9
10
11
12
13
# File 'lib/ruby_spriter/utils/image_helper.rb', line 4

def self.get_dimensions(image_path)
  # Execute ImageMagick to get image dimensions

  cmd = "magick identify -format \"%wx%h\" #{PathHelper.quote_path(image_path)}"
  stdout, _stderr, status = Open3.capture3(cmd)

  raise ProcessingError, "Failed to get image dimensions: #{image_path}" unless status.success?

  dimensions = stdout.strip.split('x')
  { width: dimensions[0].to_i, height: dimensions[1].to_i }
end