Repository navigation
Conversation
|
I really like this idea, it's actually something I've been considering for awhile now but just haven't gotten around to implementing. I think there's a better way to implement this though. We can provide a nested array syntax for styles that allow for more detailed settings (file format, etc). We can then use something like paperclip's convert_options setting to provide more detailed image processing: 'styles' => [
'large' =>
[
'geometry' => "280x280",
'format' => "png",
'convert_options' => "-gravity center -extent 280x280"
],
'small' => [
'geometry' => "50x50",
'format' => "png",
'convert_options' => "-gravity center -extent 50x50 -quality 92"
]
]So basically, this would give users an way to supply more advanced style options without having to go so far as providing a callable type as the style. |
|
I was thinking about it too, but personally I don't like the syntax of 'styles' => array(
'foobar' => array(
//
// https://imagine.readthedocs.org/en/latest/usage/effects.html
//
'effects' => array(
'gamma' => 0.7,
'grayscale',
'negative',
),
//
// https://imagine.readthedocs.org/en/latest/usage/filters.html
//
'filters' => array(
//
// We can use class that implements Imagine\Filter\FilterInterface
//
'Vendor\Some\HelpfulFilter',
//
// We can also use some of built-in filters
//
'watermark' => array(
'image' => function()
{
return (new Imagine\Gd\Imagine())
->open('/path/to/large_image.jpg');
},
'x' => '50%',
'y' => '50%',
),
//
// Or just define a closure
//
function($imagine)
{
return $imagine->thumbnail(new Imagine\Image\Box(40, 40), Imagine\Image\ImageInterface::THUMBNAIL_OUTBOUND);
},
),
),
),Please take a look at AvalancheImagineBundle. We could borrow some ideas. |
|
I really like this. I think transformations would be great to have. Let me take a look at avalanche and see what we can leverage from there too. |
|
Maybe Illuminage is also a good candidate to be a Stapler dependency, isn't it ? |
|
Is there any progress on this? I'd like to use Stapler but the quality of resized images is really bad. |
|
I'm working on this one now. I should have a solution for this sometime in the next few days. |
|
I've implemented this feature on development branch in 7c7006c. I'll be merging this into master soon. It uses the following syntax: $this->hasAttachedFile('avatar',
[
'styles' => [
'thumbnail' => '100x100#',
],
'convert_options' => [
'thumbnail' => ['quality' => 100]
]
]);You can also set the DPI: $this->hasAttachedFile('avatar',
[
'styles' => [
'thumbnail' => '100x100#',
],
'convert_options' => [
'thumbnail' => [
'quality' => 100,
'resolution-units' => ImageInterface::RESOLUTION_PIXELSPERINCH,
'resolution-x' => 150,
'resolution-y' => 120,
]
]
]); |
|
Thanks, works great! One small issue though: readme says "Please see the Imagine\Image documentation for more details." I could not find it and if it wasn't for your comment in this pull request, I would have not known how to use this feature. |
|
Yeah, I found the docs, but I didn't know what to look for. I tried searching for "convert_options" which is not present on the page. What I mean is that it's not obvious that I should be looking at the second argument to the A link to http://imagine.readthedocs.org/en/latest/usage/introduction.html#save-images and saying that it's the same as the second argument to |
The image quality of generated images isn't good as it should be so I decided to add a simple option, which allows you to set the quality of every single style with a simple @percent postfix: