webgalen/lib/webgalien/actors/crop_png_actor.rb
2018-09-21 01:25:39 +02:00

25 lines
528 B
Ruby

# Actor for cropping png
module Webgalien
class CropPngActor
include Celluloid
def perform(work_future)
work = work_future.value
work.shift!
input_path = work.input[:path]
bbox = work.input[:bbox]
output_path = File.join(TMP_PREFIX, 'crop-' + work.id + '.png')
puts "(#{work.id}) cropping capture".green
system 'convert ' \
"-crop #{bbox[:w]}x#{bbox[:h]}+#{bbox[:x]}+#{bbox[:y]} " \
"#{input_path} #{output_path}"
work.output = { path: output_path }
work
end
end
end