From 42283e6e8657b9147f7e3837823562795678543c Mon Sep 17 00:00:00 2001 From: Bromine Date: Tue, 15 Mar 2016 02:21:21 +0800 Subject: [PATCH] use binmode on capture3 --- lib/imgkit/imgkit.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/imgkit/imgkit.rb b/lib/imgkit/imgkit.rb index b42e80c..28c5d7e 100644 --- a/lib/imgkit/imgkit.rb +++ b/lib/imgkit/imgkit.rb @@ -111,8 +111,9 @@ def to_img(format = nil, path = nil) append_javascripts set_format(format) - opts = @source.html? ? {:stdin_data => @source.to_s} : {} - result, stderr = capture3(*(command(path) + [opts])) + opts = {:binmode => true} + opts[:stdin_data] = @source.to_s if @source.html? + result, stderr = capture3(*command(path), opts) result.force_encoding("ASCII-8BIT") if result.respond_to? :force_encoding raise CommandFailedError.new(command.join(' '), stderr) if path.nil? and result.size == 0 result