Craft\ImagerService::_saveTemporaryFile PHP Method

_saveTemporaryFile() private method

Save temporary file and return filename
private _saveTemporaryFile ( $imageInstance, $sourceExtension ) : string
$imageInstance
$sourceExtension
return string
    private function _saveTemporaryFile($imageInstance, $sourceExtension)
    {
        $tempPath = craft()->path->getRuntimePath() . 'imager/temp/';
        // check if the path exists
        if (!IOHelper::getRealPath($tempPath)) {
            IOHelper::createFolder($tempPath, craft()->config->get('defaultFolderPermissions'), true);
            if (!IOHelper::getRealPath($tempPath)) {
                throw new Exception(Craft::t('Temp folder “{tempPath}” does not exist and could not be created', array('tempPath' => $tempPath)));
            }
        }
        $targetFilePath = $tempPath . md5(time()) . '.' . $sourceExtension;
        $saveOptions = array('jpeg_quality' => 100, 'png_compression_level' => 1, 'flatten' => true);
        $imageInstance->save($targetFilePath, $saveOptions);
        return $targetFilePath;
    }