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

Added PasteFilterLoader #118

Merged
merged 4 commits into from
Feb 13, 2013
Merged

Added PasteFilterLoader #118

merged 4 commits into from
Feb 13, 2013

Conversation

lmcd
Copy link
Contributor

@lmcd lmcd commented Nov 7, 2012

Added a filter loader for the 'Paste' filter. I really think there ought to be loaders for all the in-built Imagine filters so everything works out the box.

Example configuration for adding a watermark to an image:

liip_imagine:
    filter_sets:
        product_image:
            quality: 90
            filters:
                paste: { start: [577, 375], image: web/img/watermark.png }

public function load(ImageInterface $image, array $options = array())
{
list($x, $y) = $options['start'];
$destImage = $this->imagine->open($this->rootPath.'/../'.$options['image']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the path altered here with /../?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kernel.root_dir points to app/. I figured it'd be more practical if the image path was relative to the project root directory instead of the kernel root directory.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then you should pass the correct directory directly.

If one would use another directory (you may have a completely different directory structure in your project) it will be annoying that the directory is changed this way. For example I would like to have that image being generated into a temp directory as I will upload it to Amazon S3 afterwards and delete the temporary file.

@lmcd
Copy link
Contributor Author

lmcd commented Nov 7, 2012

@havvg - good point. Fixed.

@lsmith77
Copy link
Contributor

can you also add a note to the README?

@Koc
Copy link
Contributor

Koc commented Nov 14, 2012

Will it works with negative offsets?

@lsmith77
Copy link
Contributor

ping ..

public function load(ImageInterface $image, array $options = array())
{
list($x, $y) = $options['start'];
$destImage = $this->imagine->open($this->rootPath.'/'.$options['image']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about checking whether the $options['image'] is already an Imagine\Image\ImageInterface and use this directly? If it's not, the current line is just fine.

havvg added a commit that referenced this pull request Feb 13, 2013
Added PasteFilterLoader
@havvg havvg merged commit 74e1d9d into liip:master Feb 13, 2013
@havvg
Copy link
Contributor

havvg commented Feb 13, 2013

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Level: New Feature 🆕 This item involves the introduction of new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants