Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unleash the full potential of ImageMagick inside jekyll-assets #624

Open
1 task
dsmrs opened this issue Oct 15, 2019 · 3 comments
Open
1 task

unleash the full potential of ImageMagick inside jekyll-assets #624

dsmrs opened this issue Oct 15, 2019 · 3 comments
Assignees
Labels
Milestone

Comments

@dsmrs
Copy link

dsmrs commented Oct 15, 2019

  • 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
@envygeeks
Copy link
Owner

I don't know if I trust implicit forwarding with something that could potentially hit the system.

@envygeeks envygeeks self-assigned this Mar 6, 2020
@envygeeks envygeeks modified the milestones: v4.0.0, Someday Mar 6, 2020
@dsmrs
Copy link
Author

dsmrs commented Mar 11, 2020

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.

@envygeeks
Copy link
Owner

If you can provide a list I can see what I can work out. That would be a workable solution IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants