For those who cannot properly integrate Imagine like me ..
I found another WebinoImageThumb solution here that worked fine with me. Here is a little explanation if you do not want to read the full documentation:
Run: php composer.phar require webino/webino-image-thumb:dev-develop and add WebinoImageThumb as the active module in config/application.config.php , which will look like this:
<?php return array( // This should be an array of module namespaces used in the application. 'modules' => array( 'Application', 'WebinoImageThumb' ),
.. below remains the same
Now in the action of your controller, use this through the service locator, as shown below:
// at top on your controller use Zend\Validator\File\Size; use Zend\Validator\File\ImageSize; use Zend\Validator\File\IsImage; use Zend\Http\Request // in action $file = $request->getFiles(); $fileAdapter = new \Zend\File\Transfer\Adapter\Http(); $imageValidator = new IsImage(); if ($imageValidator->isValid($file['file_url']['tmp_name'])) { $fileParts = explode('.', $file['file_url']['name']); $filter = new \Zend\Filter\File\Rename(array( "target" => "file/path/to/image." . $fileParts[1], "randomize" => true, )); try { $filePath = $filter->filter($file['file_url'])['tmp_name']; $thumbnailer = $this->getServiceLocator() ->get('WebinoImageThumb'); $thumb = $thumbnailer->create($filePath, $options = [], $plugins = []); $thumb->adaptiveResize(540, 340)->save($filePath); } catch (\Exception $e) { return new ViewModel(array('form' => $form, 'file_errors' => array($e->getMessage()))); } } else { return new ViewModel(array('form' => $form, 'file_errors' => $imageValidator->getMessages())); }
Good luck .. !!
source share