Closed d9beuD closed 8 months ago
Looking good @d9beuD, thanks for putting this together.
Any chance there's a way to check MIME type without pulling in ruby-filemagic
or any other gem dependency? One of the motivations I had for this plugin was to avoid having to install extra Ruby Gems, as that's a showstopper for some deployments (Cloudflare Pages, for example). That's why the command-line interface to ImageMagick is used instead of the rmagick
gem, for example, and it means you can just put jekyll-responsive-magick.rb
in your Jekyll _plugins
folder to get it working, without having to gem install.
If there's not a way to check MIME type without additional dependencies,we might want to go back to file extension checks instead.
Thanks for your feedback @lawmurray. I understand your point of view, actually I first searched a way to do this by command line but couldn't find CLI tool that works the same for Linux, macOS and Windows.
Anyway, I think I can use ImageMagick's identify
command to check if it's an image file that is provided as it throws an error when it's not.
$ identify test.txt
identify: improper image header `test.txt' @ error/txt.c/ReadTXTImage/417.
srcset
filter does not really need is_image?
check because it already uses ImageMagick's identify
command in order to get image dimensions.
Looks good @d9beuD, thanks again for putting this together, nice piece of work! I think this unblocks you on #3 too. I may wait for that, or at least do a little more testing, before updating on RubyGems.