Sha256: a06496f7957357f0f1d0821b79f93477f5593eed3028d6ce7c2e77e6c858c704

Contents?: true

Size: 954 Bytes

Versions: 5

Compression:

Stored size: 954 Bytes

Contents

module Bulldog
  module Attachment
    class Pdf < Base
      handle :pdf
      include HasDimensions

      protected  # ---------------------------------------------------

      #
      # Return the default processor class to use for this attachment.
      #
      def default_processor_type
        :image_magick
      end

      #
      # Read the original image metadata with ImageMagick's identify
      # command.
      #
      def run_examination
        if stream.missing?
          @original_width, @original_height = 1, 1
          false
        else
          output = `identify -format "%w %h" #{stream.path}[0] 2> /dev/null`
          if $?.success? && output.present?
            @original_width, @original_height = *output.scan(/(\d+) (\d+)/).first.map{|s| s.to_i}
            true
          else
            Bulldog.logger.warn "command failed (#{$?.exitstatus})"
            false
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bulldog-0.2.4 lib/bulldog/attachment/pdf.rb
bulldog-0.2.3 lib/bulldog/attachment/pdf.rb
bulldog-0.2.2 lib/bulldog/attachment/pdf.rb
bulldog-0.2.1 lib/bulldog/attachment/pdf.rb
bulldog-0.2.0 lib/bulldog/attachment/pdf.rb