Method: Elrio::Runner#optimize

Defined in:
lib/elrio/runner.rb

#optimize(path) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/elrio/runner.rb', line 17

def optimize(path)
  image = ChunkyPNG::Image.from_file(path)
  scale = PointSize.from_filename(path)
  insets = @cap_inset_detector.detect_cap_insets(image)
  point_insets = insets / scale

  optimized_image = @image_optimizer.optimize(image, insets)

  if optimized_image
    optimized_path = optimized_path_for(path)
    optimized_image.save(optimized_path)
  end

  point_insets
end