Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private function resize($imageName, $width = null, $height = null)
- {
- $dynamicPart = $this->generateDynamicPart();
- $absolutePath =
- $this->fileSystem
- ->getDirectoryRead(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA)
- ->getAbsolutePath('customer/'.$dynamicPart.'/').$imageName.'.'.self::DEFAULT_IMG__EXTENSION;
- if (!file_exists($absolutePath)) {
- $this->log($absolutePath.' does not exist.');
- return false;
- }
- $imageResize = $this->imageFactory->create();
- $imageResize->open($absolutePath);
- $imageResize->constrainOnly(true);
- $imageResize->keepTransparency(true);
- $imageResize->keepFrame(false);
- $imageResize->keepAspectRatio(true);
- $imageResize->resize($width, $height);
- //destination folder
- //$destination = $imageResized;
- //save image
- $imageResize->save($absolutePath);
- //$resizedURL = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA).'resized/'.$width.'/'.$image;
- //return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement