Files
baclight/app/services/image_processor.rb
T
2026-03-06 10:56:20 -05:00

27 lines
668 B
Ruby

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: "employer"
)
end
end