コード例 #1
0
 /**
  * @param PhotoId $photoId
  * @param PhotoThumbSize $thumbSize
  * @return PhotoThumb | null
  */
 public function findOneBy(PhotoId $photoId, PhotoThumbSize $thumbSize)
 {
     foreach ($this->thumbs as $thumb) {
         if ($photoId->id() === $thumb->id() && $thumbSize->height() === $thumb->height() && $thumbSize->width() === $thumb->width()) {
             return $thumb;
         }
     }
 }
コード例 #2
0
 /**
  * @param ThumbId $thumbId
  * @param Photo $photo
  * @param PhotoThumbSize $thumbSize
  * @param HttpUrl $thumbHttpUrl
  * @return PhotoThumb
  */
 public function generate(ThumbId $thumbId, Photo $photo, PhotoThumbSize $thumbSize, HttpUrl $thumbHttpUrl)
 {
     $photoFile = $photo->photoFile() ? $photo->photoFile() : $this->downloadPhoto($photo->getPhotoHttpUrl());
     $thumbFile = $this->thumbGeneratorConfig->tempPath() . '/' . $thumbId->id() . '.' . self::CONVERSION_FORMAT;
     $target = new Box($thumbSize->width(), $thumbSize->height());
     $originalImage = $this->imagine->open($photoFile->filePath());
     $img = $originalImage->thumbnail($target, ImageInterface::THUMBNAIL_OUTBOUND);
     $img->save($thumbFile);
     return new PhotoThumb($thumbId, new PhotoId($photo->id()), $thumbHttpUrl, $thumbSize, new PhotoFile($thumbFile));
 }
コード例 #3
0
 public function setUp()
 {
     $this->arrayThumbPresenter = new ArrayThumbPresenter($this->getPhotoPresenterMock());
     $thumbId = new ThumbId();
     $url = new HttpUrl('http://test');
     $thumbSize = new PhotoThumbSize(15, 10);
     $this->expected = ['thumbs' => ['10x15' => ['id' => $thumbId->id(), 'url' => $url->value(), 'height' => $thumbSize->height(), 'width' => $thumbSize->width(), 'file' => '']]];
     $this->thumb = new PhotoThumb($thumbId, new PhotoId(), $url, $thumbSize);
     $this->thumbCollection = new PhotoThumbCollection([$this->thumb]);
 }
コード例 #4
0
    /**
     * @param PhotoId $photoId
     * @param PhotoThumbSize $thumbSize
     * @return PhotoThumb | null
     */
    public function findOneBy(PhotoId $photoId, PhotoThumbSize $thumbSize)
    {
        $sql = <<<SQL
SELECT * FROM "photo_thumb" WHERE photo_uuid=:photo_uuid AND height=:height AND width=:width
SQL;
        $sentence = $this->pdo->prepare($sql);
        $sentence->bindValue(':photo_uuid', $photoId->id(), \PDO::PARAM_STR);
        $sentence->bindValue(':height', $thumbSize->height(), \PDO::PARAM_INT);
        $sentence->bindValue(':width', $thumbSize->width(), \PDO::PARAM_INT);
        $sentence->execute();
        $row = $sentence->fetch(\PDO::FETCH_ASSOC);
        if ($row) {
            return $this->createPhotoThumbByRow($row);
        }
    }
コード例 #5
0
 /**
  * @param PhotoId $photoId
  * @param ResourceId $resourceId
  * @param PhotoName $photoName
  * @param PhotoThumbSize $photoThumbSize
  * @param PhotoFormat $photoFormat
  * @return HttpUrl
  */
 public function getPhotoThumbHttpUrlBy(PhotoId $photoId, ResourceId $resourceId, PhotoName $photoName, PhotoThumbSize $photoThumbSize, PhotoFormat $photoFormat)
 {
     return new HttpUrl($this->config->urlBase() . '/' . $this->getThumbUri($photoId->id(), $photoName->slug(), $photoThumbSize->width(), $photoThumbSize->height(), $photoFormat->value()));
 }
コード例 #6
0
ファイル: PhotoThumb.php プロジェクト: caminalab/phphotosuite
 /**
  * @return int
  */
 public function width()
 {
     return $this->photoThumbSize->width();
 }
コード例 #7
0
 /**
  * @param PhotoId $photoId
  * @param ResourceId $resourceId
  * @param PhotoName $photoName
  * @param PhotoThumbSize $photoThumbSize
  * @param PhotoFormat $photoFormat
  * @return HttpUrl
  */
 public function getPhotoThumbHttpUrlBy(PhotoId $photoId, ResourceId $resourceId, PhotoName $photoName, PhotoThumbSize $photoThumbSize, PhotoFormat $photoFormat)
 {
     $urlBase = $this->localStorageConfig->urlBase();
     $urlBase = $urlBase[strlen($urlBase) - 1] === '/' ? substr($urlBase, 0, -1) : $urlBase;
     return new HttpUrl(implode('/', [$urlBase, $this->getMd5Path($resourceId->id()), $photoId->id(), $photoName->slug()]) . '_' . $photoThumbSize->width() . 'x' . $photoThumbSize->height() . '.' . $photoFormat->value());
 }