Files
baclight/app/models/id_card/employer_logo.rb
T

17 lines
404 B
Ruby
Raw Normal View History

module IdCard
class EmployerLogo < ApplicationRecord
2026-03-19 00:42:27 -04:00
before_validation :calculate_aspect_ratio, if: :image_data_changed?
private
def calculate_aspect_ratio
2026-03-19 00:42:27 -04:00
image_io = StringIO.new(self.image_data)
width, height = FastImage.size(image_io)
image_ratio = width.to_f / height
if image_ratio
2026-03-19 00:42:27 -04:00
self.aspect_ratio = image_ratio.round(2)
end
end
end
end