Forums / Developer / convert an image with filters in a php script

convert an image with filters in a php script

Author Message

Jerome Despatis

Thursday 23 June 2011 8:11:35 am

Hello,

I'd like in a php script to convert an image into another with some effects. I could of course use convert via system() function

But I have already a bunch of nice filters in my image.ini

=> It would be far easier for me to use an eZ function that takes the image and apply on it several filters

Any idea ?

Carlos Revillo

Thursday 23 June 2011 9:21:08 am

hi Jerome.

Maybe you can try something like this

$image_alias_handler = new eZImageAliasHandler( $data['image'] );
$alias = $image_alias_handler->imageAlias( 'youralias' );

Being $data['image'] your image attribute.

Jerome Despatis

Thursday 23 June 2011 9:39:19 am

Thanks Carlos, but I don't understand well

You're speaking about imageAlias and so on, so you imagine I have an object and I want to process a new alias ?

That's not my case, I have indeed a foobar.png, and I'd like to apply to it some filters from image.ini, in order to have a foobar-converted.png.

I have no object at that step

Jerome Despatis

Thursday 23 June 2011 12:07:43 pm

$img = eZImageManager::instance();
$img->readINISettings();
$destinationMimeData = "/tmp";
$img->convert( $input, $destinationMimeData, "aliasname" );

Life is so easy with eZ :)

Nicolas Pastorino

Thursday 23 June 2011 12:35:26 pm

"

Life is so easy with eZ :)

"

Quote of the day !

Cheers,

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye