Gregwar\Image\Image::setCacheDir PHP Method

setCacheDir() public method

Change the caching directory.
public setCacheDir ( $cacheDir )
    public function setCacheDir($cacheDir)
    {
        $this->getCacheSystem()->setCacheDirectory($cacheDir);
        return $this;
    }

Usage Example

Example #1
0
 /**
  * Resize user avatar from uploaded picture
  * @param \Symfony\Component\HttpFoundation\File\UploadedFile|\Symfony\Component\HttpFoundation\File\File $original
  * @param int $user_id
  * @param string $size
  * @throws \Exception
  * @return null
  */
 public function resizeAndSave($original, $user_id, $size = 'small')
 {
     $sizeConvert = ['big' => [400, 400], 'medium' => [200, 200], 'small' => [100, 100]];
     if (!array_key_exists($size, $sizeConvert)) {
         return null;
     }
     $image = new Image();
     $image->setCacheDir(root . '/Private/Cache/images');
     $image->open($original->getPathname())->cropResize($sizeConvert[$size][0], $sizeConvert[$size][1])->save(root . '/upload/user/avatar/' . $size . '/' . $user_id . '.jpg', 'jpg', static::COMPRESS_QUALITY);
     return null;
 }
All Usage Examples Of Gregwar\Image\Image::setCacheDir