diff --git a/bin/wkhtmltoimage b/bin/wkhtmltoimage
index b2f3887..ffc75ce 100755
--- a/bin/wkhtmltoimage
+++ b/bin/wkhtmltoimage
@@ -1,5 +1,7 @@
#!/usr/bin/env ruby
+require 'rbconfig'
+
arch = case RUBY_PLATFORM
when /64.*linux/
'amd64'
@@ -13,6 +15,9 @@ arch = case RUBY_PLATFORM
raise "Invalid platform. Must be running linux or Mac."
end
+host_cpu = RbConfig::CONFIG['host_cpu']
+arch = 'darwin-x64' if host_cpu == 'arm' && arch == 'darwin-x86'
+
args = $*.map { |x| x.include?(' ') ? "'" + x + "'" : x }
cmd = File.expand_path "#{File.dirname(__FILE__)}/../libexec/wkhtmltoimage-#{arch}"