Esempio n. 1
0
 private function doResizeImpl(DirItem $srcDi, $w, $h)
 {
     $dim = $w . 'x' . $h;
     $cacheKey = md5("[{$srcDi}]:[{$dim}]");
     if ($this->CAHCE->has($cacheKey)) {
         return $this->CAHCE->get($cacheKey);
     }
     $dstDi = DirManager::autogen("images/{$dim}")->cdToHashFolder(null, null, $cacheKey)->getDirItem(null, $cacheKey, SYSTEM_IMG_TYPE);
     if ($dstDi->isImg()) {
         return $this->CAHCE->set($cacheKey, $dstDi);
     }
     if (!$srcDi->isImg()) {
         return $this->CAHCE->set($cacheKey, null);
     }
     PsLock::lockMethod(__CLASS__, __FUNCTION__);
     try {
         if (!$dstDi->isImg()) {
             //Картинка не была пересоздана в другом потоке
             SimpleImage::inst()->load($srcDi)->resizeSmart($w, $h)->save($dstDi, SYSTEM_IMG_TYPE)->close();
         }
     } catch (Exception $ex) {
         PsLock::unlock();
         throw $ex;
     }
     PsLock::unlock();
     return $this->CAHCE->set($cacheKey, $dstDi);
 }
Esempio n. 2
0
 /**
  * Обновляет обложку для сущности
  */
 public function updateEntityCover($ident, DirItem $cover = null)
 {
     if (!$cover instanceof DirItem || !$this->isImagesFactoryEnabled() || !$cover->isImg()) {
         return;
         //---
     }
     $this->assertHasAccess($ident);
     $this->assertAdminCanDo(__FUNCTION__, $ident);
     $this->LOGGER->info('Обновляем обложку сущности');
     PsImgEditor::copy($cover, $this->getCoverOriginal($ident));
 }