code: private function createInstance($file, $w = null, $h = null)
      {
          $container = $this->container;
          $webDir = $container->getParameter('gregwar_image.web_dir');
  
          $handlerClass = $this->handlerClass;
          /** @var ImageHandler $image */
          $image = new $handlerClass($file, $w, $h, $this->throwException, $this->fallbackImage);
  
          $image->setCacheDir($this->cacheDirectory);
          $image->setCacheDirMode($this->cacheDirMode);
          $image->setActualCacheDir($webDir.'/'.$this->cacheDirectory);
  
          if ($container->has('templating.helper.assets')) {
              $image->setFileCallback(function ($file) use ($container) {
                  return $container->get('templating.helper.assets')->getUrl($file);
              });
          } else {
              $image->setFileCallback(function ($file) use ($container) {
                  return $this->assetsPackages->getUrl($file);
              });
          }
  
          return $image;
      }
docs: Creates an instance defining the cache directory.
  
  @param string      $file
  @param string|null $w
  @param string|null $h
  
  @return ImageHandler