Sha256: dfc5b7ace672896077585de8f588ba7f4a0a2a982117be41c7cbee90170c95b9

Contents?: true

Size: 599 Bytes

Versions: 5

Compression:

Stored size: 599 Bytes

Contents

module MediaMagick
  module Image
    module Dimensions
      extend ActiveSupport::Concern

      def size
        version_key = version_name.present? ? version_name : "_original"

        begin
          if model.dimensions[version_key.to_s].nil?
            image = MiniMagick::Image.open(file.path)
            model.dimensions[version_key.to_s] = {"width" => image[:width], "height" => image[:height]}
            model.save
          end

          return model.dimensions[version_key.to_s]
        rescue
          return {"width" => 0, "height" => 0}
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
media_magick-0.4.1 lib/media_magick/image/dimensions.rb
media_magick-0.4.0 lib/media_magick/image/dimensions.rb
media_magick-0.3.3 lib/media_magick/image/dimensions.rb
media_magick-0.3.2 lib/media_magick/image/dimensions.rb
media_magick-0.3.0 lib/media_magick/image/dimensions.rb