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


PHP WideImage::load方法代码示例

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


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

示例1: runWideImage

 /**
  * Filter with wideimage (must be installed)
  *  
  * @param mixed $from
  * @param mixed $to
  * @param mixed $format
  */
 static function runWideImage($from, $to, $format)
 {
     if (!class_exists('WideImage')) {
         core::dprint('WideImage not exists!', core::E_CRIT);
         return;
     }
     core::dprint('<<Wideimage ' . __FUNCTION__ . ' ' . join(', ', $format) . ' -- ' . (string) $to, core::E_DEBUG4);
     $image = WideImage::load($from);
     /** @var $converted \WideImage_Image */
     $converted = false;
     $method = array_shift($format);
     /*
     Fatal error: Uncaught exception 'WideImage_Operation_InvalidResizeDimensionException' with message
              'Both dimensions must be larger than 0.' in vendor\spekkionu\wideimage\WideImage\Operation\Resize.php:123
     */
     if (is_callable(array($image, $method))) {
         try {
             $converted = call_user_func_array(array($image, $method), $format);
         } catch (Exception $e) {
             core::dprint(' ..convert image failed: ' . $e->getMessage(), core::E_DEBUG4);
         }
     }
     if ($converted) {
         $converted->saveToFile($to);
     }
 }
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:33,代码来源:image.php

示例2: editarAction

 public function editarAction()
 {
     $id = $this->getRequest()->getParam('id');
     $this->view->breadcrumb = array($this->title => 'gestao/banner-home/editar');
     $this->view->rs = $rs = $this->_service->getByid($id);
     if (is_null($rs)) {
         $this->_helper->flashMessenger->addMessage('Operação não permitida!');
         $this->_redirect('/gestao/banner-home/');
     }
     if ($this->_request->isPost()) {
         $data = array('id' => $rs['id'], 'titulo' => $this->_dataPost['titulo'], 'link_saibamais' => $this->_dataPost['link_saibamais'], 'link_reservar' => $this->_dataPost['link_reservar'], 'descricao' => $this->_dataPost['descricao']);
         if ($_FILES['imagem']['name'] != '') {
             require_once '/WideImage/WideImage.php';
             try {
                 $image = WideImage::load('imagem');
             } catch (Exception $e) {
                 $this->_helper->flashMessenger->addMessage('Imagem inválida!');
                 $this->_redirect('/gestao/banner-home');
             }
             $nomeImagem = date('dmYGis');
             $image->saveToFile('img/upload/' . $nomeImagem . '.jpg', 60);
             $image->crop('center', 'center', 920, 650)->saveToFile('img/upload/' . $nomeImagem . '-mobile.jpg', 60);
             $data['imagem'] = 'img/upload/' . $nomeImagem . '.jpg';
             $data['imagem_mobile'] = 'img/upload/' . $nomeImagem . '-mobile.jpg';
             unlink($rs['imagem']);
             unlink($rs['imagem_mobile']);
         }
         $return = $this->_service->update($data);
         if ($return) {
             $this->_helper->flashMessenger->addMessage('Atualizado com sucesso!');
             $this->_redirect('/gestao/banner-home/');
         }
     }
 }
开发者ID:pccnf,项目名称:sitevilla,代码行数:34,代码来源:BannerHomeController.php

示例3: execute

 function execute($image)
 {
     $mask = WideImage::load(DEMO_PATH . 'masks/' . $this->fields['mask']->value);
     $left = $this->fields['left']->value;
     $top = $this->fields['top']->value;
     return $image->applyMask($mask, $left, $top);
 }
开发者ID:alexyangfox,项目名称:Filemanager,代码行数:7,代码来源:applyMask.php

示例4: upload

 public function upload(Model $Model, $arquivo = array(), $altura = 800, $largura = 600, $pasta = null, $nome_arquivo)
 {
     // App::uses('Vendor', 'wideimage');
     App::import('Vendor', 'WideImage', array('file' => 'WideImage' . DS . 'WideImage.php'));
     App::uses('Folder', 'Utility');
     $ext = array('image/jpg', 'image/jpeg', 'image/pjpeg', 'image/x-jps', 'image/png', 'image/gif');
     if ($arquivo['error'] != 0 || $arquivo['size'] == 0) {
         return false;
     }
     $img = WideImage::load($arquivo['tmp_name']);
     $folder = new Folder();
     $pathinfo = pathinfo($arquivo['name']);
     if ($folder->create(WWW_ROOT . 'img' . DS . $pasta . DS)) {
         //se conseguiu criar o diretório eu dou permissão
         $folder->chmod(WWW_ROOT . 'img' . DS . $pasta . DS, 0755, true);
     } else {
         return false;
     }
     $pathinfo['filename'] = strtolower(Inflector::slug($pathinfo['filename'], '-'));
     $arquivo['name'] = $nome_arquivo . '.' . $pathinfo['extension'];
     $img->saveToFile(WWW_ROOT . 'img' . DS . $pasta . DS . 'original_' . $arquivo['name']);
     $img = $img->resize($largura, $altura, 'fill');
     $img->saveToFile(WWW_ROOT . 'img' . DS . $pasta . DS . $arquivo['name']);
     // debug(WWW_ROOT.'img'.DS.$pasta.DS.$arquivo['name']); die;
     return $arquivo['name'];
 }
开发者ID:vitorrampazzo,项目名称:cms,代码行数:26,代码来源:UploadBehavior.php

示例5: testRotate45

 function testRotate45()
 {
     $img = WideImage::load(IMG_PATH . '100x100-rainbow.png');
     $new = $img->rotate(45);
     $this->assertEquals(142, $new->getWidth());
     $this->assertEquals(142, $new->getHeight());
 }
开发者ID:NaszvadiG,项目名称:DivaSul,代码行数:7,代码来源:RotateTest.php

示例6: uploadBanner

 /**
  * 
  * @param array $files
  * @param array $post
  */
 public function uploadBanner(array $files, array &$post, $width = 800, $height = 350)
 {
     if (!empty($files) && $files['arquivo']['error'] == 0) {
         try {
             $extensionPermiss = array('jpg', 'jpeg', 'png', 'gif');
             /* codigo de upload */
             if (!file_exists($this->path)) {
                 mkdir($this->path);
             }
             /**
              * Verificar os dados do arquivo
              */
             $fullName = pathinfo($files['arquivo']['name'], PATHINFO_BASENAME);
             $fileName = pathinfo($files['arquivo']['name'], PATHINFO_FILENAME);
             $extension = pathinfo($files['arquivo']['name'], PATHINFO_EXTENSION);
             $pathFile = $this->path . DS . URL::sanitizeTitleWithDashes($fileName) . '.' . $extension;
             if (in_array(strtolower($extension), $extensionPermiss)) {
                 require_once "Library/wideimage/WideImage.php";
                 WideImage::load($files['arquivo']['tmp_name'])->resize($width, $height, 'outside')->saveToFile($pathFile, 90);
                 $post['imagem'] = URL::sanitizeTitleWithDashes($fileName) . '.' . $extension;
             } else {
                 throw new Exception('é permitido somente arquivos do tipo ' . join(',', $extensionPermiss));
             }
         } catch (Exception $ex) {
             throw $ex;
         }
     }
 }
开发者ID:brunoblauzius,项目名称:sistema,代码行数:33,代码来源:Evento.php

示例7: display

 public function display($filename, $setting_index = 0)
 {
     if (!file_exists($filename)) {
         throw new Exception('Image <code>' . $filename . '</code> could not be found.');
     }
     // Get size
     if (isset($this->settings[$setting_index])) {
         $setting = $this->settings[$setting_index];
     } else {
         $setting_index = 0;
         $setting = NULL;
     }
     $cache_filename = $this->cache_dir . md5($filename . $setting_index);
     // Remove cache
     if (file_exists($cache_filename) && (filectime($filename) > filectime($cache_filename) || self::FORCE_GENERATE_CACHE)) {
         unlink($cache_filename);
     }
     // Generate image and cache
     if (!file_exists($cache_filename)) {
         $img = $this->generateCache($filename, $cache_filename, $setting);
     } else {
         $img = WideImage::load($cache_filename);
     }
     // Display
     if ($setting) {
         $img->output($setting['format'], $setting['quality']);
     } else {
         $img->output(self::DEFAULT_FORMAT, self::DEFAULT_QUALITY);
     }
     $img->destroy();
 }
开发者ID:kyrst,项目名称:base,代码行数:31,代码来源:imager.php

示例8: array

 /**
 * @public
 * 
 * @param array $param Valores das variáveis
 * 
 * @example $this->WideImageOne($param = array(
  'Path'=>  array($this->getPathFile('destaque')), //Destino
  'Name'=>$_POST['nome'], //Nome da Foto
  'Size'=>array('239x239'), //Tamanho da Foto
  'File'=>'foto',             //Nome do $_FILES
  //'Delete'=>$foto['foto'], //Deve ser usando quando for upadte
  ));
 * 
 * @return string Retorna o nome da foto
 */
 public function WideImageOne($param)
 {
     self::extensions('wideImage.lib.WideImage');
     $file = $_FILES[$param['File']];
     $type = explode('/', $file['type']);
     $name = $this->caracteres($param['Name'] . '-' . rand(1, 300) . '.' . $type[1]);
     $i = 0;
     $count = count($param['Path']);
     while ($i < $count) {
         if (!is_dir($param['Path'][$i])) {
             echo "Path \n{$param['Path'][$i]}\n naõ encotrado";
             die;
         }
         if (isset($param['Delete']) && !empty($param['Delete'])) {
             if (!$this->WideImageDelete(array('Path' => $param['Path'][$i], 'Name' => $param['Delete']))) {
                 echo '';
             }
         }
         $_load = WideImage::load($file['tmp_name']);
         $size = explode('x', $param['Size'][$i]);
         $_resize = $_load->resize((int) $size[0], (int) $size[1]);
         $_resize->saveToFile($param['Path'][$i] . $name);
         unset($_load, $_resize);
         chmod($param['Path'][$i] . $name, 775);
         ++$i;
     }
     return $name;
 }
开发者ID:FabiolaBraga,项目名称:kandaframework,代码行数:43,代码来源:Crop.php

示例9: execute

 function execute($image, $request)
 {
     $overlay = WideImage::load(DEMO_PATH . 'images/' . $this->fields['overlay']->value);
     $left = $this->fields['left']->value;
     $top = $this->fields['top']->value;
     $opacity = $this->fields['opacity']->value;
     return $image->merge($overlay, $left, $top, $opacity);
 }
开发者ID:AmandaNatallie,项目名称:RequisitosPA,代码行数:8,代码来源:merge.php

示例10: test

 function test()
 {
     $img = WideImage::load(IMG_PATH . '100x100-color-hole.gif');
     $result = $img->correctGamma(1, 2);
     $this->assertTrue($result instanceof WideImage_PaletteImage);
     $this->assertTrue($result->isTransparent());
     $this->assertEquals(100, $result->getWidth());
     $this->assertEquals(100, $result->getHeight());
 }
开发者ID:AmandaNatallie,项目名称:RequisitosPA,代码行数:9,代码来源:CorrectGammaTest.php

示例11: cria

 public function cria()
 {
     if (!empty($_GET['idCamp'])) {
         $_SESSION['idCamp'] = $_GET['idCamp'];
     }
     if (isset($_SESSION['idCamp'])) {
         $dados = $dados2 = $dados4 = $this->db->get_where('campanha', array('id' => $_SESSION['idCamp']))->row_array(0);
         $dados3 = array();
         $emp = str_replace(";", ",", $dados['empreendimento']);
         if ($emp != "") {
             $dados3 = $this->db->query("SELECT * FROM empreendimento WHERE id IN ({$emp}) ORDER BY empreendimento ASC")->result_array();
         }
         if (count($dados3) > 0) {
             include './application/assets/misc/wideimage/WideImage.php';
             foreach ($dados3 as $d) {
                 $pastaOrigem = '../' . $d['pasta'] . '/galeria';
                 $pastaDest = '../' . $dados['pasta'] . '/galeria';
                 # Copia
                 $origem = $pastaOrigem . "/" . $d['topo'];
                 $destino = $pastaDest . "/preview_" . $d['id'] . '.jpg';
                 copy($origem, $destino);
                 list($width, $height, $type, $attr) = getimagesize($origem);
                 # Resize
                 $img = WideImage::load($destino);
                 $resized = $img->resize(400, null);
                 $resized = $resized->crop('center', 'top', 400, 260);
                 $resized->saveToFile($destino);
                 $img->destroy();
             }
         }
     } else {
         $dados = UtilFunctions::getColunaTable('campanha');
     }
     if (isset($_POST['formSubmit']) && $_POST['formSubmit'] == true) {
         switch ($_POST['passo']) {
             case 1:
                 if ($dados['id'] == "") {
                     $this->create();
                 } else {
                     $this->update();
                 }
                 break;
             case 2:
                 $this->scripts();
                 break;
             case 3:
                 $this->empreendimento();
                 break;
             case 4:
                 $this->video();
                 break;
         }
     }
     $this->load->view('topo');
     $this->load->view(strtolower($this->area) . '/cria', array('dados' => $dados, 'dados2' => isset($dados2) ? $dados2 : "", 'dados3' => isset($dados3) ? $dados3 : "", 'dados4' => isset($dados4) ? $dados4 : ""));
     $this->load->view('rodape');
 }
开发者ID:rogeriolopesalmeida,项目名称:so-vantagem-imoveis,代码行数:57,代码来源:Campanha.php

示例12: testApplyFilter

 function testApplyFilter()
 {
     $img = WideImage::load(IMG_PATH . '100x100-color-hole.gif');
     $result = $img->applyFilter(IMG_FILTER_EDGEDETECT);
     $this->assertTrue($result instanceof WideImage_TrueColorImage);
     $this->assertTrue($result->isTransparent());
     $this->assertEquals(100, $result->getWidth());
     $this->assertEquals(100, $result->getHeight());
 }
开发者ID:alexyangfox,项目名称:Filemanager,代码行数:9,代码来源:ApplyFilterTest.php

示例13: testAutocropHalfImageBug

 function testAutocropHalfImageBug()
 {
     $img = WideImage::load(IMG_PATH . '100x100-red-spot-half-cut.png');
     $cropped = $img->autocrop();
     $this->assertTrue($cropped instanceof WideImage_TrueColorImage);
     $this->assertEquals(22, $cropped->getWidth());
     $this->assertEquals(23, $cropped->getHeight());
     $this->assertRGBNear($cropped->getRGBAt(10, 10), 255, 0, 0);
 }
开发者ID:alexyangfox,项目名称:Filemanager,代码行数:9,代码来源:AutoCrop.test.php

示例14: testApplyConvolution

 public function testApplyConvolution()
 {
     $img = WideImage::load(IMG_PATH . '100x100-color-hole.gif');
     $result = $img->applyConvolution([[2, 0, 0], [0, -1, 0], [0, 0, -1]], 1, 220);
     $this->assertTrue($result instanceof WideImage_TrueColorImage);
     $this->assertTrue($result->isTransparent());
     $this->assertEquals(100, $result->getWidth());
     $this->assertEquals(100, $result->getHeight());
 }
开发者ID:NablusTechMeetups,项目名称:web,代码行数:9,代码来源:ApplyConvolutionTest.php

示例15: load

 /**
  * Load an image an instanciate a new Image class
  * 
  * @param string $source    Path to the image to load
  * @return Image 
  */
 public static function load($source)
 {
     $instance = parent::load($source);
     $instance->source = $source;
     $instance->basename = basename($source);
     $instance->name = substr($instance->basename, 0, strrpos($instance->basename, '.'));
     $instance->extension = substr($instance->basename, strrpos($instance->basename, '.'));
     return $instance;
 }
开发者ID:salomalo,项目名称:php-oxygen,代码行数:15,代码来源:image.class.php


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