jekyll-assets
jekyll-assets copied to clipboard
unleash the full potential of ImageMagick inside jekyll-assets
- [ ] This feature is not on the latest version
Request
I'm trying to build a super low consumption website, one way is to "dithering" the images from the website. The option is already available in ImageMagick, but not on the ones supported by jekyll-assets
.
Not a Jekyll expert, neither ruby, but I would love to have this feature implemented.
A (bad) example of implementation
{% asset my_image.png magick:resize=930 magick:colors=4 magick:colorspace=gray magick:define=png:color-type=3 %}
In assets/plugins/proxy/magick.rb
def process
img = ::MiniMagick::Image.new(@file)
magick_format(img) if @args[:magick][:format]
img.combine_options do |c|
@args[:magick].keys.reject { |k| k == :format }.each do |k|
m = "magick_#{k}"
if respond_to?(m, true)
method(m).arity == 2 ? send(m, img, c) : send(m, c)
end
# send any key to ImageMagick
if img.respond_to?(k, true)
c.send(k, @args[:magick][k])
end
end
end
@file
ensure
img&.destroy!
end
I don't know if I trust implicit forwarding with something that could potentially hit the system.
I don't know if I trust implicit forwarding with something that could potentially hit the system.
Agreed! That's why I said a "bad" implementation ^^ We could build an array with only the safest functions of ImageMagick? to filter what we pipe to it.
If you can provide a list I can see what I can work out. That would be a workable solution IMO.