Sha256: 41da7bec12ee916ee1fc1c60e2ea803172ff3311f41cbaa568c48b4fd17d6859
Contents?: true
Size: 998 Bytes
Versions: 2
Compression:
Stored size: 998 Bytes
Contents
# frozen_string_literal: true require "zip" require "nokogiri" module Consolidate module Docx class Image < SimpleDelegator # Path to use when referencing this image from other documents def media_path = "media/#{name}" # Path to use when storing this image within the docx def storage_path = "word/#{media_path}" # Convert width from pixels to EMU def width = super * emu_per_width_pixel # Convert height from pixels to EMU def height = super * emu_per_height_pixel # Get the width of this image in EMU up to a maximum page width (also in EMU) def clamped_width(maximum = 7_772_400) = [width, maximum].min # Get the height of this image in EMU adjusted for a maximum page width (also in EMU) def clamped_height(maximum = 7_772_400) = (height * clamped_width(maximum).to_f / width.to_f).to_i def emu_per_width_pixel = 914_400 / dpi[:x] def emu_per_height_pixel = 914_400 / dpi[:y] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
standard-procedure-consolidate-0.4.1 | lib/consolidate/docx/image.rb |
standard-procedure-consolidate-0.4.0 | lib/consolidate/docx/image.rb |