File tree Expand file tree Collapse file tree
lib/jekyll_picture_tag/parsers Expand file tree Collapse file tree Original file line number Diff line number Diff 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.'
Original file line number Diff line number Diff 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
6373end
You can’t perform that action at this time.
0 commit comments