Files
baclight/app/services/image_processor.rb
T

27 lines
667 B
Ruby
Raw Normal View History

class ImageProcessor
def initialize(image_path, new_filename = nil)
@image_path = image_path
@new_filename = new_filename
end
def call
if @new_filename
filename = @new_filename
else
filename = File.basename(@image_path)
end
binary_data = File.binread(@image_path)
# binary_data = File.open(@image_path, 'rb').read
meme_type = Marcel::MimeType.for Pathname.new(@image_path)
CardLogoFile.create(
filename: filename,
image_data: binary_data,
content_type: meme_type,
logo_type: "network"
)
end
end