fedibird-fe/lib/paperclip/dimension_extractor.rb

15 lines
419 B
Ruby
Raw Permalink Normal View History

# frozen_string_literal: true
module Paperclip
class DimensionExtractor < Paperclip::Processor
def make
geometry = options.fetch(:file_geometry_parser).from_file(@file)
attachment.instance.width = geometry.width if attachment.instance.respond_to?(:width)
attachment.instance.height = geometry.height if attachment.instance.respond_to?(:height)
File.open(@file.path)
end
end
end