Closed heinzmuller closed 10 years ago
Sure, you can write a custom filter.
For the Facade it would look like (given your filter is aliased to 'Convert' => 'cv' and format option is f
)
JitImage::source('path/to/myimage.tif')->scale(50)->filter('cv', 'f=jpg');
In your filter's run()
e.g. (Acme\Filters\Convert\ImagickCvFilter
) method you would simple call
$this->driver->setOutputType('jpg');
You can register your own filter like:
Event::listen('jitimage.registerfitler', function ($driverName) {
return [
'Convert' => 'FilterClass'
];
});
Also see this part of the serviceprovider. Should give you a hint how filters are registered internally.
'jitimage.registerfitler' is fired once for each driver, so you can utilize $driverName
to determine which filterclass to install for each driver.
This isn't really documented. I have to apologize. I'll add this to the docs asap.
Best, Thomas
Thanks a bunch for the quick reply, i'll dive in right away :)
Oh, I was wrong, there's a short example on how to register custom filters:
https://github.com/iwyg/jitimage/blob/master/src/Thapp/JitImage/JitImageServiceProvider.php#L303
Typo: jitimage.registerfitler
oh yea, that one's awful. Thanks
hm, gave this a quick shot but I'm unable to convert tiff to jpg (both imagemagick and imagick compiled against libtiff). Seems like when compiling imagemagick against libtiff jpeg support is dropped (at least in homebrew). So in theory I'd say it will work for im and imagick drivers.
Ok works for me with im and imagick drivers.
However, there's no GD support for tiff files
Any chance it is possible to add the option to save the generated image in another format?
Sort of like this
JitImage::source('path/to/myimage.tif')->scale(50)->convert('jpg');
And for recipes