本文整理汇总了PHP中WideImage类的典型用法代码示例。如果您正苦于以下问题:PHP WideImage类的具体用法?PHP WideImage怎么用?PHP WideImage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WideImage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editar
public static function editar()
{
$cracha = new Cracha();
$cracha->selecionarPorId($_GET['id']);
if (!empty($_POST)) {
$nomeCracha = $_POST['nome'];
$idParticipante = $_POST['idParticipante'];
$funcao = $_POST['funcao'];
if (!empty($_FILES["foto_cracha"]["name"])) {
$nomeFoto = $idParticipante . '-' . Util::substituiCaracteres($nomeCracha) . '.' . pathinfo($_FILES['foto_cracha']['name'], PATHINFO_EXTENSION);
$foto = WideImage::loadFromUpload('foto_cracha');
$imagem = $foto->crop($_POST['foto_x'], $_POST['foto_y'], $_POST['foto_w'], $_POST['foto_h']);
@unlink('../fotosParticipantes/' . $nomeFoto);
$imagem->saveToFile('../fotosParticipantes/' . $nomeFoto);
$cracha->foto = $nomeFoto;
}
$cracha->nome = $nomeCracha;
$cracha->funcao = $funcao;
$cracha->fk_participante = $idParticipante;
$cracha->salvar();
self::redirecionar(Configuracao::$baseUrl . 'cracha/listar' . Configuracao::$extensaoPadrao);
}
self::$variaveis = array('cracha' => $cracha);
self::$corpo = "editar";
self::renderizar(self::$viewController);
}
示例2: 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());
}
示例3: testMagicCallDrawRectangle
function testMagicCallDrawRectangle()
{
$img = WideImage::createTrueColorImage(10, 10);
$canvas = $img->getCanvas();
$canvas->filledRectangle(1, 1, 5, 5, $img->allocateColorAlpha(255, 0, 0, 64));
$this->assertRGBAt($img, 3, 3, array('red' => 255, 'green' => 0, 'blue' => 0, 'alpha' => 64));
}
示例4: 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);
}
示例5: execute
/**
* Returns an image with a resized canvas
*
* The image is filled with $color. Use $scale to determine, when to resize.
*
* @param WideImage_Image $img
* @param smart_coordinate $width
* @param smart_coordinate $height
* @param smart_coordinate $left
* @param smart_coordinate $top
* @param int $color
* @param string $scale 'up', 'down', 'any'
* @return WideImage_Image
*/
function execute($img, $width, $height, $left, $top, $color, $scale)
{
$new_width = WideImage_Coordinate::fix($width, $img->getWidth());
$new_height = WideImage_Coordinate::fix($width, $img->getHeight());
if ($scale == 'down') {
$new_width = min($new_width, $img->getWidth());
$new_height = min($new_height, $img->getHeight());
} elseif ($scale == 'up') {
$new_width = max($new_width, $img->getWidth());
$new_height = max($new_height, $img->getHeight());
}
$new = WideImage::createTrueColorImage($new_width, $new_height);
if ($img->isTrueColor()) {
if ($color === null) {
$color = $new->allocateColorAlpha(0, 0, 0, 127);
}
} else {
imagepalettecopy($new->getHandle(), $img->getHandle());
if ($color === null) {
if ($img->isTransparent()) {
$new->copyTransparencyFrom($img);
$tc_rgb = $img->getTransparentColorRGB();
$color = $new->allocateColorAlpha($tc_rgb);
} else {
$color = $new->allocateColorAlpha(255, 0, 127, 127);
}
imagecolortransparent($new->getHandle(), $color);
}
}
$new->fill(0, 0, $color);
$x = WideImage_Coordinate::fix($left, $new->getWidth(), $img->getWidth());
$y = WideImage_Coordinate::fix($top, $new->getHeight(), $img->getHeight());
$img->copyTo($new, $x, $y);
return $new;
}
示例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;
}
}
}
示例7: 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);
}
}
示例8: 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/');
}
}
}
示例9: 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;
}
示例10: addAction
public function addAction()
{
$config = Config::getInstance();
$config = $config->getConfig();
$Cars = new Cars();
$this->view->data = $Cars->getCategory();
$model = $this->request->getPost('model');
$marka = $this->request->getPost('marka_id');
$opis = $this->request->getPost('opis');
$zdjecie = $this->request->getFiles('zdjecie');
if ($model == NULL && $marka == NULL && $opis == NULL && $zdjecie == NULL) {
$this->view->display('add');
} else {
if ($model == NULL || $marka == NULL || $opis == NULL || $zdjecie == NULL) {
echo "Uzupelnij wszystkie pola";
} else {
$podpis = date("Y-m-d G:i:s", time());
$zdjecie = WideImage::loadFromUpload('zdjecie');
$zdjecie->saveToFile($config['DOC_ROOT'] . $config['CUSTOM_IMG_DIR'] . $podpis . '.png');
$Car = new Cars();
$Car->saveCar($model, $marka, $opis, $podpis);
header('location: ' . Url::getUrl('car', 'list', array('status' => 8)));
}
}
}
示例11: 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'];
}
示例12: 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();
}
示例13: 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);
}
示例14: 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');
}
示例15: 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);
}