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


PHP WideImage::loadFromFile方法代码示例

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


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

示例1: testInvalidImageFile

 /**
  * @expectedException WideImage_InvalidImageSourceException
  */
 function testInvalidImageFile()
 {
     WideImage::loadFromFile(IMG_PATH . 'fakeimage.png');
 }
开发者ID:thaida,项目名称:CMS,代码行数:7,代码来源:WideImageTest.php

示例2: png_jpeg_to_jpg

 function png_jpeg_to_jpg($link)
 {
     //		var_dump($link);
     //		var_dump(pathinfo($link, PATHINFO_EXTENSION));exit;
     if (pathinfo($link, PATHINFO_EXTENSION) == 'jpeg') {
         $oldName = $link;
         $new_name = substr($link, 0, -5);
         WideImage::loadFromFile($link)->saveToFile($new_name . ".jpg", 80);
         unlink($oldName);
     } elseif (pathinfo($link, PATHINFO_EXTENSION) == 'png') {
         $oldName = $link;
         $new_name = substr($link, 0, -4);
         WideImage::loadFromFile($link)->saveToFile($new_name . ".jpg", 80);
         unlink($oldName);
     }
 }
开发者ID:villos,项目名称:tree_admin,代码行数:16,代码来源:AddFiles.php

示例3: showImage

 /**
  *
  * @param type $dto
  * @param type $endereco
  */
 public static function showImage($dto, $endereco)
 {
     $endereco = explode("/", $endereco);
     $nameImage = array_reverse($endereco);
     $pasta = current(explode('application', __DIR__)) . 'data' . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . 'anexo-artefato' . DIRECTORY_SEPARATOR;
     $fileinfo = pathinfo($pasta . $nameImage[0]);
     $image = \WideImage::loadFromFile($pasta . $nameImage[0]);
     if ($dto->getResize()) {
         $image = $image->resize($dto->getWidth(), $dto->getHeight(), 'outside');
     }
     if ($dto->getCrop()) {
         $image = $image->resize($dto->getWidth(), $dto->getHeight(), 'outside')->crop('50% - ' . ceil($dto->getWidth() / 2), '50% - ' . ceil($dto->getHeight() / 2), $dto->getWidth(), $dto->getHeight());
     }
     unset($dto);
     unset($pasta);
     $image->output(strtolower($fileinfo['extension']));
     $image->destroy();
 }
开发者ID:sgdoc,项目名称:sgdoce-codigo,代码行数:23,代码来源:Imagem.php

示例4: generateThumbnail

 /**
  * Generates a thumbnail image for a slice
  *
  * @param $thumb_x
  * @param $thumb_y
  * @param bool $keep_aspect
  * @param null $background_color
  * @param string $extension
  *
  */
 public function generateThumbnail($thumb_x, $thumb_y, $keep_aspect = true, $background_color = null, $extension = "thumb")
 {
     $slices_dir = dirname($this->File->getFullPath());
     $thumb_path = $this->getThumbFullPath($extension);
     // get the slice image
     RokGallery_Memory::adjustLimitForImage($this->xsize, $this->ysize);
     $slice_image = WideImage::loadFromFile($this->getFullPath());
     if ($background_color == 'transparent' || empty($background_color)) {
         $background_color = null;
     }
     // if he image size is smaller then the thumbnail size
     // resize the canvas with optioned color and place in center
     if ($this->xsize < $thumb_x && $this->ysize < $thumb_y) {
         // Resize canvas
         RokGallery_Memory::adjustLimitForImage($thumb_x, $thumb_y);
         $thumb_image = $slice_image->resizeCanvas($thumb_x, $thumb_y, 'center', 'center', $background_color == null ? $background_color : $slice_image->allocateColor(RokGallery_Helper::html2rgb($background_color)));
         $slice_image->destroy();
         unset($slice_image);
         // write out image
         $thumb_image->saveToFile($thumb_path, RokGallery_Helper::getImageQuality($this->File->type));
         RokGallery_Queue_FileCreate::add($thumb_path);
         $thumb_image->destroy();
         unset($thumb_image);
     } else {
         if ($keep_aspect) {
             // Keep the aspect Ratio
             RokGallery_Memory::adjustLimitForImage($thumb_x, $thumb_y);
             $thumb_image_after_resize = $slice_image->resize($thumb_x, $thumb_y);
             $slice_image->destroy();
             unset($slice_image);
             // fill in blank space
             RokGallery_Memory::adjustLimitForImage($thumb_x, $thumb_y);
             $thumb_image = $thumb_image_after_resize->resizeCanvas($thumb_x, $thumb_y, 'center', 'center', $background_color == null ? $background_color : $thumb_image_after_resize->allocateColor(RokGallery_Helper::html2rgb($background_color)));
             $thumb_image_after_resize->destroy();
             unset($thumb_image_after_resize);
             // write out image
             $thumb_image->saveToFile($thumb_path, RokGallery_Helper::getImageQuality($this->File->type));
             RokGallery_Queue_FileCreate::add($thumb_path);
             $thumb_image->destroy();
             unset($thumb_image);
         } else {
             // Create thumbnail but dont make thumbnail keep the aspect ratio
             $source_aspect_ratio = $this->xsize / $this->ysize;
             $desired_aspect_ratio = $thumb_x / $thumb_y;
             $temp_width = $thumb_x;
             $temp_height = $thumb_y;
             $temp_left = 0;
             $temp_top = 0;
             if ($source_aspect_ratio > $desired_aspect_ratio) {
                 $temp_height = $thumb_y;
                 $temp_width = (int) round($thumb_y * $source_aspect_ratio);
                 $temp_left = (int) round(($temp_width - $thumb_x) / 2);
                 $temp_top = 0;
             } elseif ($source_aspect_ratio < $desired_aspect_ratio) {
                 $temp_width = $thumb_x;
                 $temp_height = (int) round($thumb_x / $source_aspect_ratio);
                 $temp_left = 0;
                 $temp_top = (int) round(($temp_height - $thumb_y) / 2);
             }
             RokGallery_Memory::adjustLimitForImage($temp_width, $temp_height);
             $thumb_image_after_resize = $slice_image->resize($temp_width, $temp_height);
             $slice_image->destroy();
             unset($slice_image);
             RokGallery_Memory::adjustLimitForImage($thumb_x, $thumb_y);
             $thumb_image = $thumb_image_after_resize->crop($temp_left, $temp_top, $thumb_x, $thumb_y);
             $thumb_image_after_resize->destroy();
             unset($thumb_image_after_resize);
             // write out image
             $thumb_image->saveToFile($thumb_path, RokGallery_Helper::getImageQuality($this->File->type));
             RokGallery_Queue_FileCreate::add($thumb_path);
             $thumb_image->destroy();
             unset($thumb_image);
         }
     }
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:85,代码来源:Slice.php


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