samedi 11 février 2017

Laravel Stapler watermark choose resized image

I am using the Stapler package for image processing and I am implementing the watermark option. In the default example the image used to get the watermark image is the uploaded image but in my case I want to a resized image which is processed also with the Stapler.

Here is my code:

     'styles' => [
        'large' => '836x572#',
        'medium' => '200x160#',
        'thumb' => '100x80#',
        'watermarked' => function($file, $imagine) {
            $watermark = $imagine->open('assets/images/logo.png');          // Create an instance of ImageInterface for the watermark image.
            $image     = $imagine->open($file->getRealPath());              // Create an instance of ImageInterface for the uploaded image.
            $size      = $image->getSize();                                 // Get the size of the uploaded image.
            $watermarkSize = $watermark->getSize();                         // Get the size of the watermark image.

            // Calculate the placement of the watermark (we're aiming for the bottom right corner here).
            $bottomRight = new Imagine\Image\Point($size->getWidth() - $watermarkSize->getWidth(), $size->getHeight() - $watermarkSize->getHeight());

            // Paste the watermark onto the image.
            $image->paste($watermark, $bottomRight);

            // Return the Imagine\Image\ImageInterface instance.
            return $image;
        },
    ],
    'url' => '/media/products/hero/:attachment/:id_partition/:style/:filename',
    'default_url' => '/packages/enlight/bulb/img/missing.png'

Any idea how to define example the "large" image instead the uploaded image which is not resized?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2kU8hpt
via IFTTT

Aucun commentaire:

Enregistrer un commentaire