I want to use LiipImagineBundle to resize my uploaded pictures in the controller.
$extension = $file->guessExtension();
$newfilename = sha1(uniqid(mt_rand(), true));
$tmp_folder = $this->get('kernel')->getRootDir() . '/../web/uploads/tmp/'; // folder to 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 the following error:
Attempted to call method "get" on class "Liip\ImagineBundle\Imagine\Filter\FilterManager" in C:\...\UserController.php line xx. Did you mean to call: "getFilterConfiguration"?
Then i try instead
$newimage_string = $this->container->get('liip_imagine.filter.manager')->getFilterConfiguration($request, 'profilepic', $processedImage, $tmpImagePathRel);
And it brings me
Warning: fwrite() expects parameter 2 to be string, object given in C:\..
I hardly cannot find any documentation or examples to get this task done :( Im pretty disappointed with the bundle docs ://
Any help is really appreciated!
Thanks in advance!