Project rename
All checks were successful
CI Pipeline / build (push) Successful in 12s

This commit is contained in:
2025-12-02 13:21:13 +01:00
parent 29ebb9a8d1
commit dec346254c
36 changed files with 114 additions and 114 deletions

38
lib/notare/nodes/image.rb Normal file
View File

@@ -0,0 +1,38 @@
# frozen_string_literal: true
module Notare
module Nodes
class Image < Base
attr_reader :path, :width_emu, :height_emu, :rid, :filename
EMUS_PER_INCH = 914_400
EMUS_PER_CM = 360_000
DEFAULT_DPI = 96
def initialize(path, rid:, width_emu:, height_emu:)
super()
@path = path
@rid = rid
@width_emu = width_emu
@height_emu = height_emu
@filename = "image#{rid.delete_prefix("rId")}.#{extension}"
end
def extension
case File.extname(@path).downcase
when ".png" then "png"
when ".jpg", ".jpeg" then "jpeg"
else raise ArgumentError, "Unsupported image format: #{File.extname(@path)}"
end
end
def content_type
extension == "png" ? "image/png" : "image/jpeg"
end
def doc_pr_id
rid.delete_prefix("rId").to_i
end
end
end
end