Skip to content

Commit 23ffdd4

Browse files
committed
Adding Fallback to convert
ubuntu uses IM6 by default which doesn't support magick
1 parent a211d03 commit 23ffdd4

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

lib/jekyll_picture_tag/parsers/image_backend.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ def magick_formats
3434
.first
3535
.delete_prefix('Delegates (built-in):')
3636
.split
37+
elsif command?('convert')
38+
@magick_formats ||= `convert -version`
39+
.scan(/Delegates.*/)
40+
.first
41+
.delete_prefix('Delegates (built-in):')
42+
.split
3743
else
3844
@magick_formats = []
3945
end
@@ -56,7 +62,7 @@ def error_string(format)
5662
else
5763
'Libvips is not installed.'
5864
end
59-
str << if command?('magick')
65+
str << if command?('magick') || command?('convert')
6066
"Imagemagick (installed) supports: \"#{magick_formats.join(', ')}\"."
6167
else
6268
'Imagemagick is not installed.'

test/test_helper.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def temp_dir(*descendents)
4949
# them doesn't support some image format. This returns an array of image
5050
# formats which we care about, and which are locally supported.
5151
def supported_formats
52-
output = `vips --list` + `magick --version`
52+
magick_command = command?('magick') ? `magick` : `convert`
53+
output = `vips --list` + `#{magick_command} --version`
5354

5455
formats = %w[jpg png webp gif jp2 avif].select do |format|
5556
output.include? format
@@ -60,4 +61,13 @@ def supported_formats
6061

6162
formats
6263
end
64+
65+
def command?(command)
66+
is_windows = RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
67+
if is_windows
68+
system("where #{command} > NUL 2>&1")
69+
else
70+
system("which #{command} > /dev/null 2>&1")
71+
end
72+
end
6373
end

0 commit comments

Comments
 (0)