symfony - LiipImagineBundle: How to apply filter in controller? -


i want use liipimaginebundle resize uploaded pictures in controller.

  $extension = $file->guessextension();   $newfilename = sha1(uniqid(mt_rand(), true));   $tmp_folder = $this->get('kernel')->getrootdir() . '/../web/uploads/tmp/'; // folder store unfiltered temp file   $tmp_imagename = $newfilename.'.'.$extension;   $file->move($tmp_folder, $tmp_imagename);    $tmpimagepathrel = '/uploads/tmp/' . $tmp_imagename;   $processedimage = $this->container->get('liip_imagine.data.manager')->find('profilepic', $tmpimagepathrel);   $newimage_string = $this->container->get('liip_imagine.filter.manager')->get($request, 'profilepic', $processedimage, $tmpimagepathrel)->getcontent();    unlink($tmp_folder . $tmp_imagename); // eliminate unfiltered temp file.   $perm_folder = $this->get('kernel')->getrootdir() . '/../web/uploads/userimages/';   $perm_imagepath = $perm_folder . $newfilename . '.jpeg';   $f = fopen($perm_imagepathh, 'w');   fwrite($f, $newimage_string);    fclose($f); 

that brings following error:

attempted call method "get" on class "liip\imaginebundle\imagine\filter\filtermanager" in c:\...\usercontroller.php line xx. did mean call: "getfilterconfiguration"? 

then try instead

$newimage_string = $this->container->get('liip_imagine.filter.manager')->getfilterconfiguration($request, 'profilepic', $processedimage, $tmpimagepathrel); 

and brings me

warning: fwrite() expects parameter 2 string, object given in c:\.. 

i hardly cannot find documentation or examples task done :( im pretty disappointed bundle docs ://

any appreciated!

thanks in advance!

ok got work, maybe usefull others:

$newimage_string = $this->container->get('liip_imagine.filter.manager')->applyfilter($processedimage, 'profilepic')->getcontent(); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

jquery - Keeping Kendo Datepicker in min/max range -