Sha256: 69ea8045d29379ea37e752dfea33b70bc500d2a78a98b9deb16639927ac6e018

Contents?: true

Size: 922 Bytes

Versions: 1

Compression:

Stored size: 922 Bytes

Contents

module OpenXml
  module Pptx
    module Parts
      class Image < OpenXml::Parts::UnparsedPart
        attr_reader :path, :content_type, :relationship_type

        def initialize(*args, extension: ".png")
          super(*args)
          @path = Pathname.new("ppt/media/image#{extension}")
          @content_type = IMAGE_TYPES.fetch(extension)
          @relationship_type = IMAGE_RELATIONSHIP_TYPE
        end

        def path=(value)
          @path = Pathname.new(value)
        end

        IMAGE_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image".freeze

        IMAGE_TYPES = {
          ".jpeg" => "image/jpeg",
          ".jpg" => "image/jpeg",
          ".png" => "image/png",
          ".gif" => "image/gif",
          ".bmp" => "image/bmp",
          ".tiff" => "image/tiff",
          ".jxr" => "image/vnd.ms-photo"
        }.freeze

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
openxml-pptx-0.2.2 lib/openxml/pptx/parts/image.rb