Class: Shipping::PreProcessUpsLabel
- Inherits:
-
BaseService
- Object
- BaseService
- Shipping::PreProcessUpsLabel
- Defined in:
- app/services/shipping/pre_process_ups_label.rb
Instance Method Summary collapse
Methods inherited from BaseService
#initialize, #log_debug, #log_error, #log_info, #log_warning, #logger, #options, #tagged_logger
Constructor Details
This class inherits a constructor from BaseService
Instance Method Details
#process(gif_file_path, out_file_name: nil) ⇒ Object
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 |
# File 'app/services/shipping/pre_process_ups_label.rb', line 4 def process(gif_file_path, out_file_name: nil) require 'vips' directory_path = File.dirname(gif_file_path) base_name = File.basename(gif_file_path, '.gif') out_file_name ||= "#{directory_path}/#{base_name}.png" # Load the image image = Vips::Image.new_from_file(gif_file_path) # Rotate 90 degrees clockwise image = image.rot(:d90) # Add 20px white border on all sides # Embed image in a larger canvas with white background image = image.( 20, 20, # x, y offset image.width + 40, image.height + 40, # new dimensions extend: :white ) # Write as PNG image.write_to_file(out_file_name) out_file_name end |