class HexaPDF::Document::Images

Such cases are all handled by this class automatically.
as a mask for another image, not all image objects found in a PDF are really used as images.
Images themselves are represented by the HexaPDF::Type::Image class.Since an image can be used
through the HexaPDF::Document#images method.
This class provides methods for managing the images embedded in a PDF file. It is available

def add(file_or_io)

same path name), the already existing image object is returned.
If the image has been added to the PDF before (i.e. if there is an image object with the

Adds the image from the given file or IO to the PDF document and returns the image object.

images.add(io) -> image
images.add(file) -> image
:call-seq:
def add(file_or_io)
  name = if file_or_io.kind_of?(String)
           file_or_io
         elsif file_or_io.respond_to?(:to_path)
           file_or_io.to_path
         end
  if name
    name = File.absolute_path(name)
    image = find {|im| im.source_path == name }
  end
  unless image
    image = image_loader_for(file_or_io).load(@document, file_or_io)
    image.source_path = name
  end
  image
end

def each(&block)

mask are not.
Note that only real images are yielded which means, for example, that images used as soft

Iterates over all images in the PDF document.

images.each -> Enumerator
images.each {|image| block } -> images
:call-seq:
def each(&block)
  images = @document.each.select do |obj|
    next unless obj.kind_of?(HexaPDF::Dictionary)
    obj[:Subtype] == :Image && !obj[:ImageMask]
  end
  masks = images.each_with_object([]) do |image, temp|
    temp << image[:Mask] if image[:Mask].kind_of?(Stream)
    temp << image[:SMask] if image[:SMask].kind_of?(Stream)
  end
  (images - masks).each(&block)
end

def image_loader_for(file_or_io)

raises an error if no suitable image loader is found.
Returns the image loader (see HexaPDF::ImageLoader) for the given file or IO stream or
def image_loader_for(file_or_io)
  @document.config['image_loader'].each_index do |index|
    loader = @document.config.constantize('image_loader', index) do
      raise HexaPDF::Error, "Couldn't retrieve image loader from configuration"
    end
    return loader if loader.handles?(file_or_io)
  end
  raise HexaPDF::Error, "Couldn't find suitable image loader"
end

def initialize(document)

Creates a new Images object for the given PDF document.
def initialize(document)
  @document = document
end