Files
baclight/app/models/id_card/employer_logo.rb
T
2026-03-13 08:47:13 -04:00

17 lines
388 B
Ruby

module IdCard
class EmployerLogo < ApplicationRecord
before_save :calculate_aspect_ratio, if: :image_data_changed?
private
def calculate_aspect_ratio
image_io = StringIO.new(image_data)
width, height = FastImage.size(image_io)
image_ratio = width.to_f / height
if image_ratio
aspect_ratio = image_ratio.round(2)
end
end
end
end