From e28ea07e1a3a94cdbdfef84f80ec0e25420b3d94 Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Fri, 5 Oct 2018 20:42:58 +1000 Subject: [PATCH] transposed max width and height for images --- Gemfile.lock | 8 ++++---- lib/html2doc/mime.rb | 4 ++-- lib/html2doc/version.rb | 2 +- spec/html2doc_spec.rb | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3d5ed7d..5652961 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - html2doc (0.8.3) + html2doc (0.8.4) asciimath htmlentities (~> 4.3.4) image_size @@ -14,7 +14,7 @@ PATH GEM remote: https://rubygems.org/ specs: - asciimath (1.0.5) + asciimath (1.0.6) ast (2.4.0) byebug (9.1.0) coderay (1.1.2) @@ -53,7 +53,7 @@ GEM mime-types-data (3.2018.0812) mini_portile2 (2.3.0) nenv (0.3.0) - nokogiri (1.8.4) + nokogiri (1.8.5) mini_portile2 (~> 2.3.0) notiffany (0.1.1) nenv (~> 0.1) @@ -85,7 +85,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.8.0) rspec-support (3.8.0) - rubocop (0.58.2) + rubocop (0.59.2) jaro_winkler (~> 1.5.1) parallel (~> 1.10) parser (>= 2.5, != 2.5.1.1) diff --git a/lib/html2doc/mime.rb b/lib/html2doc/mime.rb index 8f9382a..d46d28f 100644 --- a/lib/html2doc/mime.rb +++ b/lib/html2doc/mime.rb @@ -59,7 +59,7 @@ def self.mime_package(result, filename, dir) File.open("#{filename}.doc", "w:UTF-8") { |f| f.write mhtml } end - # max height for Word document is 400, max width is 680 + # max width for Word document is 400, max height is 680 def self.image_resize(i, maxheight, maxwidth) realSize = ImageSize.path(i["src"]).size s = [i["width"].to_i, i["height"].to_i] @@ -81,7 +81,7 @@ def self.image_cleanup(docxml, dir) uuid = UUIDTools::UUID.random_create.to_s new_full_filename = File.join(dir, "#{uuid}.#{matched[:suffix]}") FileUtils.cp i["src"], new_full_filename - i["width"], i["height"] = image_resize(i, 400, 680) + i["width"], i["height"] = image_resize(i, 680, 400) i["src"] = new_full_filename end docxml diff --git a/lib/html2doc/version.rb b/lib/html2doc/version.rb index a73ffb3..bbf389b 100644 --- a/lib/html2doc/version.rb +++ b/lib/html2doc/version.rb @@ -1,3 +1,3 @@ module Html2Doc - VERSION = "0.8.3".freeze + VERSION = "0.8.4".freeze end diff --git a/spec/html2doc_spec.rb b/spec/html2doc_spec.rb index 0b82180..f84fc97 100644 --- a/spec/html2doc_spec.rb +++ b/spec/html2doc_spec.rb @@ -517,7 +517,7 @@ def image_clean(x) expect(testdoc).to match(%r{Content-Type: image/png}) expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT) #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END} - #{image_clean(word_body('', '
'))} + #{image_clean(word_body('', '
'))} #{image_clean(WORD_FTR3)} OUTPUT end @@ -529,7 +529,7 @@ def image_clean(x) expect(testdoc).to match(%r{Content-Type: image/gif}) expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT) #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END} - #{image_clean(word_body('', '
'))} + #{image_clean(word_body('', '
'))} #{image_clean(WORD_FTR3).gsub(/image\.png/, "image.gif")} OUTPUT end @@ -541,7 +541,7 @@ def image_clean(x) expect(testdoc).to match(%r{Content-Type: image/jpeg}) expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT) #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END} - #{image_clean(word_body('', '
'))} + #{image_clean(word_body('', '
'))} #{image_clean(WORD_FTR3).gsub(/image\.png/, "image.jpg")} OUTPUT end