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

[Feature request]: Add watermark #4

Closed
taimaiduc opened this issue Sep 28, 2018 · 8 comments
Closed

[Feature request]: Add watermark #4

taimaiduc opened this issue Sep 28, 2018 · 8 comments
Labels
enhancement New feature or request

Comments

@taimaiduc
Copy link

Can we backup original image then add watermark to an image?

@saqueib saqueib added the enhancement New feature or request label Sep 28, 2018
@saqueib
Copy link
Member

saqueib commented Sep 28, 2018

what type of watermark did you want to apply, Text or Image based?

I think we can add this feature with the following options:

 protected static $imageFields = [
        'poster' => [
            'width' => 800,
            'height' => 600,
            'watermark' => [
                'type' => 'text', // can be 'image' or 'text'
                'source' => 'Copyright QCod', // 'text' or 'image path'
                'position' => `bottom-right`,
                'offset' => [x, y]
            ]
        ]

what you think, any suggestion.

@taimaiduc
Copy link
Author

taimaiduc commented Sep 28, 2018

protected static $imageFields = [
        'poster' => [
            'width' => 800,
            'height' => 600,
            'watermark' => [
                'type' => 'text', // can be 'image' or 'text'
               'style' => 'single or repeat'
                'source' => 'Copyright QCod', // 'text' or 'image path'
                'position' => `bottom-right`,
                'offset' => [x, y]
            ]
        ]

image

You should always keep original before add watermark or resize or crop I think it very important
Do you think so ?

We can add a command to remove all image and create another one when user change watermark source.

You know what I mean?

For example, we have an image with watermark is xxxxx but somehow we need to change xxxxx to ccccc

@saqueib
Copy link
Member

saqueib commented Sep 28, 2018

I think you should use manual resize for this feature.
Just disable the auto upload and resize the image however you want, you will have full Intervention Image instance access:

// disable the auto upload 
$model->setImagesField(['cover' => ['auto_upload' => false]);

// maually resize it
$originalImage = request()->file('orginalFile');
$resizedImage = $user->resizeImage($imageFile, [ 'width' => 800 ]);

// now watermark it 
// check this to implement it http://image.intervention.io/api/insert

I will add a generic watermark option in this package later. I am afraid your use case won't be covered completely with this, but here is what I will be adding:

protected static $imageFields = [
        'poster' => [
            'width' => 800,
            'height' => 600,
            'keep_original' => true, // keep the original with `original-` prefixed filename
            'watermark' => [
                'type' => 'text', // can be 'image' or 'text'
                'style' => 'single or repeat'
                'source' => 'Copyright QCod', // 'text' or 'image path'
                'position' => `bottom-right`,
                'offset' => [x, y]
            ]
        ]

@shadoWalker89
Copy link
Contributor

How about adding a before_save and after_save options that will pass the intervention instance as a parameter and the developper can do whatever he wants with the image

protected static $imageFields = [
        'poster' => [
            'width' => 800,
            'height' => 600,
            'keep_original' => true, // keep the original with `original-` prefixed filename
            'before_save' =>function($image) {
                 // Do some stuff ...
            },
            'after_save' =>function($image) {
                 // Create the another image with the watermark
            },
        ]

I can make the PR for the callbacks

@saqueib
Copy link
Member

saqueib commented Sep 30, 2018

@shadoWalker89 that will be great if you can pr this, give option to pass a closer or a class name with handle method on that class will get triggered

@shadoWalker89
Copy link
Contributor

@saqueib PR is ready for inspection #8

@saqueib
Copy link
Member

saqueib commented Oct 2, 2018

Closing #8 feature added with hooks

@saqueib saqueib closed this as completed Oct 2, 2018
@taimaiduc
Copy link
Author

Thanks guys

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

No branches or pull requests

3 participants