当前位置: 首页>>代码示例>>PHP>>正文


PHP OC_Image::scaleDownToFit方法代码示例

本文整理汇总了PHP中OC_Image::scaleDownToFit方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Image::scaleDownToFit方法的具体用法?PHP OC_Image::scaleDownToFit怎么用?PHP OC_Image::scaleDownToFit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OC_Image的用法示例。


在下文中一共展示了OC_Image::scaleDownToFit方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getThumbnail

 /**
  * {@inheritDoc}
  */
 public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
 {
     //get fileinfo
     $fileInfo = $fileview->getFileInfo($path);
     if (!$fileInfo) {
         return false;
     }
     $maxSizeForImages = \OC::$server->getConfig()->getSystemValue('preview_max_filesize_image', 50);
     $size = $fileInfo->getSize();
     if ($maxSizeForImages !== -1 && $size > $maxSizeForImages * 1024 * 1024) {
         return false;
     }
     $image = new \OC_Image();
     $useTempFile = $fileInfo->isEncrypted() || !$fileInfo->getStorage()->isLocal();
     if ($useTempFile) {
         $fileName = $fileview->toTmpFile($path);
     } else {
         $fileName = $fileview->getLocalFile($path);
     }
     $image->loadFromFile($fileName);
     $image->fixOrientation();
     if ($useTempFile) {
         unlink($fileName);
     }
     if ($image->valid()) {
         $image->scaleDownToFit($maxX, $maxY);
         return $image;
     }
     return false;
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:33,代码来源:Image.php

示例2: getThumbnail

 /**
  * {@inheritDoc}
  */
 public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
 {
     $this->initCmd();
     if (is_null($this->cmd)) {
         return false;
     }
     $absPath = $fileview->toTmpFile($path);
     $tmpDir = \OC::$server->getTempManager()->getTempBaseDir();
     $defaultParameters = ' -env:UserInstallation=file://' . escapeshellarg($tmpDir . '/owncloud-' . \OC_Util::getInstanceId() . '/') . ' --headless --nologo --nofirststartwizard --invisible --norestore --convert-to pdf --outdir ';
     $clParameters = \OCP\Config::getSystemValue('preview_office_cl_parameters', $defaultParameters);
     $exec = $this->cmd . $clParameters . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath);
     shell_exec($exec);
     //create imagick object from pdf
     $pdfPreview = null;
     try {
         list($dirname, , , $filename) = array_values(pathinfo($absPath));
         $pdfPreview = $dirname . '/' . $filename . '.pdf';
         $pdf = new \imagick($pdfPreview . '[0]');
         $pdf->setImageFormat('jpg');
     } catch (\Exception $e) {
         unlink($absPath);
         unlink($pdfPreview);
         \OCP\Util::writeLog('core', $e->getmessage(), \OCP\Util::ERROR);
         return false;
     }
     $image = new \OC_Image();
     $image->loadFromData($pdf);
     unlink($absPath);
     unlink($pdfPreview);
     if ($image->valid()) {
         $image->scaleDownToFit($maxX, $maxY);
         return $image;
     }
     return false;
 }
开发者ID:loulancn,项目名称:core,代码行数:38,代码来源:office.php

示例3: getThumbnail

	/**
	 * {@inheritDoc}
	 */
	public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
		try {
			$svg = new \Imagick();
			$svg->setBackgroundColor(new \ImagickPixel('transparent'));

			$content = stream_get_contents($fileview->fopen($path, 'r'));
			if (substr($content, 0, 5) !== '<?xml') {
				$content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $content;
			}

			// Do not parse SVG files with references
			if (stripos($content, 'xlink:href') !== false) {
				return false;
			}

			$svg->readImageBlob($content);
			$svg->setImageFormat('png32');
		} catch (\Exception $e) {
			\OCP\Util::writeLog('core', $e->getmessage(), \OCP\Util::ERROR);
			return false;
		}

		//new image object
		$image = new \OC_Image();
		$image->loadFromData($svg);
		//check if image object is valid
		if ($image->valid()) {
			$image->scaleDownToFit($maxX, $maxY);

			return $image;
		}
		return false;
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:36,代码来源:svg.php

示例4: getThumbnail

 /**
  * {@inheritDoc}
  */
 public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
 {
     $getID3 = new \getID3();
     $tmpPath = $fileview->toTmpFile($path);
     $tags = $getID3->analyze($tmpPath);
     \getid3_lib::CopyTagsToComments($tags);
     if (isset($tags['id3v2']['APIC'][0]['data'])) {
         $picture = @$tags['id3v2']['APIC'][0]['data'];
         unlink($tmpPath);
         $image = new \OC_Image();
         $image->loadFromData($picture);
         if ($image->valid()) {
             $image->scaleDownToFit($maxX, $maxY);
             return $image;
         }
     }
     return $this->getNoCoverThumbnail();
 }
开发者ID:samj1912,项目名称:repo,代码行数:21,代码来源:mp3.php

示例5: getThumbnail

 /**
  * {@inheritDoc}
  */
 public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
 {
     $getID3 = new ID3Parser();
     $tmpPath = $fileview->toTmpFile($path);
     $tags = $getID3->analyze($tmpPath);
     unlink($tmpPath);
     $picture = isset($tags['id3v2']['APIC'][0]['data']) ? $tags['id3v2']['APIC'][0]['data'] : null;
     if (is_null($picture) && isset($tags['id3v2']['PIC'][0]['data'])) {
         $picture = $tags['id3v2']['PIC'][0]['data'];
     }
     if (!is_null($picture)) {
         $image = new \OC_Image();
         $image->loadFromData($picture);
         if ($image->valid()) {
             $image->scaleDownToFit($maxX, $maxY);
             return $image;
         }
     }
     return $this->getNoCoverThumbnail();
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:23,代码来源:MP3.php

示例6: generateThumbNail

 /**
  * @param int $maxX
  * @param int $maxY
  * @param string $absPath
  * @param int $second
  * @return bool|\OCP\IImage
  */
 private function generateThumbNail($maxX, $maxY, $absPath, $second)
 {
     $tmpPath = \OC_Helper::tmpFile();
     if (self::$avconvBinary) {
         $cmd = self::$avconvBinary . ' -an -y -ss ' . escapeshellarg($second) . ' -i ' . escapeshellarg($absPath) . ' -f mjpeg -vframes 1 -vsync 1 ' . escapeshellarg($tmpPath) . ' > /dev/null 2>&1';
     } else {
         $cmd = self::$ffmpegBinary . ' -y -ss ' . escapeshellarg($second) . ' -i ' . escapeshellarg($absPath) . ' -f mjpeg -vframes 1' . ' ' . escapeshellarg($tmpPath) . ' > /dev/null 2>&1';
     }
     exec($cmd, $output, $returnCode);
     if ($returnCode === 0) {
         $image = new \OC_Image();
         $image->loadFromFile($tmpPath);
         unlink($tmpPath);
         if ($image->valid()) {
             $image->scaleDownToFit($maxX, $maxY);
             return $image;
         }
     }
     unlink($tmpPath);
     return false;
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:28,代码来源:movie.php

示例7: testScaleDownWhenBigger

 /**
  * @dataProvider largeSampleProvider
  *
  * @param string $filename
  * @param int[] $asked
  * @param int[] $expected
  */
 public function testScaleDownWhenBigger($filename, $asked, $expected)
 {
     $img = new \OC_Image(OC::$SERVERROOT . '/tests/data/' . $filename);
     //$this->assertTrue($img->scaleDownToFit($asked[0], $asked[1]));
     $img->scaleDownToFit($asked[0], $asked[1]);
     $this->assertEquals($expected[0], $img->width());
     $this->assertEquals($expected[1], $img->height());
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:15,代码来源:ImageTest.php


注:本文中的OC_Image::scaleDownToFit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。