src/storage/BaseFileSystemStorage.php
public function createImage($fileId, $filterId)
    {
        $image = StorageImage::find()->where(['file_id' => $fileId, 'filter_id' => $filterId])->one();

        // the image exists already in the database and the file system
        if ($image && $image->fileExists) {
            return $image;
        }

        $file = StorageFile::findOne($fileId);

        if (!$file) {
            return false;
        }
        // create the new image name
        $fileName = $filterId.'_'.$file->name_new_compound;

        $fromTempFile = tempnam(sys_get_temp_dir(), 'fromFile');
        $fromTempFile.= $fileName;

        $content = $file->getContent();

        // it seems the content can not be found.
        if ($content === false) {
            return false;
        }

        $writeFile = FileHelper::writeFile($fromTempFile, $content);

        // unable to write the temp file
        if (!$writeFile) {
            return false;
        }

        // create a temp file
        $tempFile = tempnam(sys_get_temp_dir(), 'destFile');
        $tempFile.= $fileName;

        // there is no filter, which means we create an image version for a given file.
        if (empty($filterId)) {
            @copy($fromTempFile, $tempFile);
        } else {
            $filter = StorageFilter::findOne($filterId);
            if (!$filter || !$filter->applyFilterChain($fromTempFile, $tempFile)) {
                return false;
            }
        }

        $resolution = Storage::getImageResolution($tempFile);
        // now copy the file to the storage system
        $this->fileSystemSaveFile($tempFile, $fileName);
        unlink($tempFile);
        unlink($fromTempFile);

        $this->flushImageArray();

        // ensure the existing of the model
        if ($image) {
            $image->resolution_height = $resolution['height'];
            $image->resolution_width = $resolution['width'];
            $image->save();

            return $image;
        }

        $image = new StorageImage();
        $image->file_id = $fileId;
        $image->filter_id = $filterId;
        $image->resolution_height = $resolution['height'];
        $image->resolution_width = $resolution['width'];
        if (!$image->save()) {
            return false;
        }

        return $image;
    }
public function createImage($fileId, $filterId)
    {
        $image = StorageImage::find()->where(['file_id' => $fileId, 'filter_id' => $filterId])->one();

        // the image exists already in the database and the file system
        if ($image && $image->fileExists) {
            return $image;
        }

        $file = StorageFile::findOne($fileId);

        if (!$file) {
            return false;
        }
        // create the new image name
        $fileName = $filterId.'_'.$file->name_new_compound;

        $fromTempFile = tempnam(sys_get_temp_dir(), 'fromFile');
        $fromTempFile.= $fileName;

        $content = $file->getContent();

        // it seems the content can not be found.
        if ($content === false) {
            return false;
        }

        $writeFile = FileHelper::writeFile($fromTempFile, $content);

        // unable to write the temp file
        if (!$writeFile) {
            return false;
        }

        // create a temp file
        $tempFile = tempnam(sys_get_temp_dir(), 'destFile');
        $tempFile.= $fileName;

        // there is no filter, which means we create an image version for a given file.
        if (empty($filterId)) {
            @copy($fromTempFile, $tempFile);
        } else {
            $filter = StorageFilter::findOne($filterId);
            if (!$filter || !$filter->applyFilterChain($fromTempFile, $tempFile)) {
                return false;
            }
        }

        $resolution = Storage::getImageResolution($tempFile);
        // now copy the file to the storage system
        $this->fileSystemSaveFile($tempFile, $fileName);
        unlink($tempFile);
        unlink($fromTempFile);

        $this->flushImageArray();

        // ensure the existing of the model
        if ($image) {
            $image->resolution_height = $resolution['height'];
            $image->resolution_width = $resolution['width'];
            $image->save();

            return $image;
        }

        $image = new StorageImage();
        $image->file_id = $fileId;
        $image->filter_id = $filterId;
        $image->resolution_height = $resolution['height'];
        $image->resolution_width = $resolution['width'];
        if (!$image->save()) {
            return false;
        }

        return $image;
    }
public function createImage ( $ fileId , $ filterId ) { $ image = StorageImage :: find ( ) -> where ( [ 'file_id' => $ fileId , 'filter_id' => $ filterId ] ) -> one ( ) ; // the image exists already in the database and the file system if ( $ image && $ image -> fileExists ) { return $ image ; } $ file = StorageFile :: findOne ( $ fileId ) ; if ( ! $ file ) { return false ; } // create the new image name $ fileName = $ filterId . '_' . $ file -> name_new_compound ; $ fromTempFile = tempnam ( sys_get_temp_dir ( ) , 'fromFile' ) ; $ fromTempFile .= $ fileName ; $ content = $ file -> getContent ( ) ; // it seems the content can not be found. if ( $ content === false ) { return false ; } $ writeFile = FileHelper :: writeFile ( $ fromTempFile , $ content ) ; // unable to write the temp file if ( ! $ writeFile ) { return false ; } // create a temp file $ tempFile = tempnam ( sys_get_temp_dir ( ) , 'destFile' ) ; $ tempFile .= $ fileName ; // there is no filter, which means we create an image version for a given file. if ( empty ( $ filterId ) ) { @ copy ( $ fromTempFile , $ tempFile ) ; } else { $ filter = StorageFilter :: findOne ( $ filterId ) ; if ( ! $ filter || ! $ filter -> applyFilterChain ( $ fromTempFile , $ tempFile ) ) { return false ; } } $ resolution = Storage :: getImageResolution ( $ tempFile ) ; // now copy the file to the storage system $ this -> fileSystemSaveFile ( $ tempFile , $ fileName ) ; unlink ( $ tempFile ) ; unlink ( $ fromTempFile ) ; $ this -> flushImageArray ( ) ; // ensure the existing of the model if ( $ image ) { $ image -> resolution_height = $ resolution [ 'height' ] ; $ image -> resolution_width = $ resolution [ 'width' ] ; $ image -> save ( ) ; return $ image ; } $ image = new StorageImage ( ) ; $ image -> file_id = $ fileId ; $ image -> filter_id = $ filterId ; $ image -> resolution_height = $ resolution [ 'height' ] ; $ image -> resolution_width = $ resolution [ 'width' ] ; if ( ! $ image -> save ( ) ) { return false ; } return $ image ; }
Just creating the image based on input informations without usage of storage files or images list.

@param integer $fileId The id of the file to create  filter of
@param integer $filterId The filter id to apply on the given file.
@since 1.2.2.1
@return \luya\admin\models\StorageImage|false Returns the storage image model on success, otherwise false.
Just creating the image based on input informations without usage of storage files or images list .