Esempio n. 1
0
 /**
  * Asks core for a preview based on our criteria
  *
  * @todo Need to read scaling setting from settings
  *
  * @param bool $keepAspect
  *
  * @return \OC_Image
  */
 private function getPreviewFromCore($keepAspect)
 {
     list($maxX, $maxY) = $this->dims;
     $this->preview->setMaxX($maxX);
     $this->preview->setMaxY($maxY);
     $this->preview->setScalingUp(false);
     $this->preview->setKeepAspect($keepAspect);
     //$this->logger->debug("[PreviewService] preview {preview}", ['preview' => $this->preview]);
     $previewData = $this->preview->getPreview();
     return $previewData;
 }
Esempio n. 2
0
 /**
  * Asks core for a preview based on our criteria
  *
  * @todo Need to read scaling setting from settings
  *
  * @param bool $keepAspect
  *
  * @return \OC_Image
  */
 private function getPreviewFromCore($keepAspect)
 {
     //$this->logger->debug("[PreviewService] Fetching the preview");
     list($maxX, $maxY) = $this->dims;
     $this->preview->setMaxX($maxX);
     $this->preview->setMaxY($maxY);
     $this->preview->setScalingUp(false);
     $this->preview->setKeepAspect($keepAspect);
     //$this->logger->debug("[PreviewService] preview {preview}", ['preview' => $this->preview]);
     try {
         // Can generate encryption Exceptions...
         $previewData = $this->preview->getPreview();
     } catch (\Exception $exception) {
         return null;
     }
     return $previewData;
 }
Esempio n. 3
0
 /**
  * @param $filePath User/files/....
  * @return string
  */
 public static function prevImg($filePath)
 {
     //        $filePath = 'files/Photos/Paris.jpg';
     //$preview = \OC::$server->getPreviewManager()->createPreview($filePath, 128, 128, true);
     $conf = explode('/files/', $filePath);
     $preview = new Preview($conf[0], '/', 'files/' . $conf[1], 128, 128, true);
     $resp = new DataDisplayResponse($preview->getPreview()->data(), Http::STATUS_OK, ['Content-Type' => 'image/png']);
     $src = 'data: ' . $preview->getPreview()->mimeType() . ';base64,' . base64_encode($resp->render());
     return $src;
 }