public function setBaseFile($file)
    {
        $this->isBaseFilePlaceholder = false;

        if ($file && 0 !== strpos($file, '/', 0)) {
            $file = '/' . $file;
        }
        $baseDir = $this->uploader->getBasePath();

        if ($file) {
            if (!$this->fileExists($baseDir . $file) || !$this->checkMemory($baseDir . $file)) {
                $file = null;
            }
        }
        if (!$file) {
            $this->isBaseFilePlaceholder = true;
            $this->newFile = true;
            return $this;
        }

        $baseFile = $baseDir . $file;

        if (!$file || !$this->mediaDirectory->isFile($baseFile)) {
            throw new \Exception(__('We can\'t find the image file.'));
        }

        $this->baseFile = $baseFile;

        // build new filename (most important params)
        $path = [
            $this->uploader->getBasePath(),
            'cache',
            $this->storeManager->getStore()->getId(),
            $path[] = $this->getDestinationSubdir(),
        ];
        if (!empty($this->width) || !empty($this->height)) {
            $path[] = "{$this->width}x{$this->height}";
        }

        // add misk params as a hash
        $miscParams = [
            ($this->keepAspectRatio ? '' : 'non') . 'proportional',
            ($this->keepFrame ? '' : 'no') . 'frame',
            ($this->keepTransparency ? '' : 'no') . 'transparency',
            ($this->constrainOnly ? 'do' : 'not') . 'constrainonly',
            $this->rgbToString($this->backgroundColor),
            'angle' . $this->angle,
            'quality' . $this->quality,
        ];

        // if has watermark add watermark params to hash
        if ($this->getWatermarkFile()) {
            $miscParams[] = $this->getWatermarkFile();
            $miscParams[] = $this->getWatermarkImageOpacity();
            $miscParams[] = $this->getWatermarkPosition();
            $miscParams[] = $this->getWatermarkWidth();
            $miscParams[] = $this->getWatermarkHeight();
        }

        $path[] = md5(implode('_', $miscParams));

        // append prepared filename
        $this->newFile = implode('/', $path) . $file;
        // the $file contains heading slash

        return $this;
    }