Sha256: 595c4041b0a0b54930b9c83c8cf53c8d19f4dd2ef770a3e3c2f8252afe356306

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

module Riiif
  # Represents a IIIF request
  class Transformation
    attr_reader :crop, :size, :quality, :rotation, :format
    def initialize(crop, size, quality, rotation, format)
      @crop = crop
      @size = size
      @quality = quality
      @rotation = rotation
      @format = format
    end

    # Create a clone of this Transformation, scaled by the factor
    # @param [Integer] factor the scale for the new transformation
    # @return [Transformation] a new transformation, scaled by factor
    def reduce(factor)
      Transformation.new(crop.dup,
                         size.reduce(factor),
                         quality,
                         rotation,
                         format)
    end

    # Create a clone of this Transformation, without the crop
    # @return [Transformation] a new transformation
    # TODO: it would be nice if we didn't need image_info
    def without_crop(image_info)
      Transformation.new(Region::Full.new(image_info),
                         size.dup,
                         quality,
                         rotation,
                         format)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
riiif-2.0.0.beta2 app/models/riiif/transformation.rb
riiif-2.0.0.beta1 app/models/riiif/transformation.rb