lawmurray / jekyll-responsive-magick

A Jekyll plugin for responsive images using ImageMagick. Works with Jekyll 4.
https://indii.org/software/jekyll-responsive-magick
Apache License 2.0
11 stars 1 forks source link

Add support for `image/*` MIME type #5

Closed d9beuD closed 8 months ago

d9beuD commented 8 months ago
lawmurray commented 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.

d9beuD commented 8 months ago

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.
d9beuD commented 8 months ago

srcset filter does not really need is_image? check because it already uses ImageMagick's identify command in order to get image dimensions.

lawmurray commented 8 months ago

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.