Skip to content

Commit

Permalink
transposed max width and height for images
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Oct 5, 2018
1 parent b0d9624 commit e28ea07
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
html2doc (0.8.3)
html2doc (0.8.4)
asciimath
htmlentities (~> 4.3.4)
image_size
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/html2doc/mime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/html2doc/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Html2Doc
VERSION = "0.8.3".freeze
VERSION = "0.8.4".freeze
end
6 changes: 3 additions & 3 deletions spec/html2doc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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('<img src="test_files/cb7b0d19-891e-4634-815a-570d019d454c.png" width="412" height="400"></img>', '<div style="mso-element:footnote-list"/>'))}
#{image_clean(word_body('<img src="test_files/cb7b0d19-891e-4634-815a-570d019d454c.png" width="400" height="388"></img>', '<div style="mso-element:footnote-list"/>'))}
#{image_clean(WORD_FTR3)}
OUTPUT
end
Expand All @@ -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('<img src="test_files/cb7b0d19-891e-4634-815a-570d019d454c.gif" width="680" height="202"></img>', '<div style="mso-element:footnote-list"/>'))}
#{image_clean(word_body('<img src="test_files/cb7b0d19-891e-4634-815a-570d019d454c.gif" width="400" height="118"></img>', '<div style="mso-element:footnote-list"/>'))}
#{image_clean(WORD_FTR3).gsub(/image\.png/, "image.gif")}
OUTPUT
end
Expand All @@ -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('<img src="test_files/cb7b0d19-891e-4634-815a-570d019d454c.jpg" width="122" height="400"></img>', '<div style="mso-element:footnote-list"/>'))}
#{image_clean(word_body('<img src="test_files/cb7b0d19-891e-4634-815a-570d019d454c.jpg" width="208" height="680"></img>', '<div style="mso-element:footnote-list"/>'))}
#{image_clean(WORD_FTR3).gsub(/image\.png/, "image.jpg")}
OUTPUT
end
Expand Down

0 comments on commit e28ea07

Please sign in to comment.