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

Size of watermark (Vips) #110

Open
9mm opened this issue Apr 5, 2023 · 1 comment
Open

Size of watermark (Vips) #110

9mm opened this issue Apr 5, 2023 · 1 comment

Comments

@9mm
Copy link

9mm commented Apr 5, 2023

I have the following:

    has_one_attached :cover_image do |image|
      image.variant :square_medium,
        format: 'jpg',
        resize_to_fill: [600, 600],
        composite: ['app/assets/images/watermark.png', {
          gravity: 'south-west',
          offset: [10, 10],
        }],
        saver: { subsample_mode: 'on', strip: true, quality: 85 }
    end

How would I change the width of the overlay? I notice regardless of what size the image is it always appears to be the same size on the watermark.

Based on the docs it seems like something like this Vips::Image.new_from_file('app/assets/images/watermark.png') would work but that raises an exception.

Thanks

Edit: Nevermind on "same size", it would appear that is ActiveStorage caching/hashing arguments. Still it would be really nice to dynamically size it

@janko
Copy link
Owner

janko commented Jun 17, 2024

Active Storage doesn't support dynamic processing, you have to encode everything at the time you're generating the link. It would be great if Active Storage supported registering custom operations, similar to what Shrine does. Some block that would yield an ImageProcessing::Builder instance or a Vips::Image object and allow hooking into the processing pipeline, which would be called when the operation is being applied.

I know I'm replying late, but what would the composition look like performed directly on Vips::Image (without Active Storage)? That would help me understand what needs to be done better.

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

No branches or pull requests

2 participants