本文整理汇总了PHP中sfImage类的典型用法代码示例。如果您正苦于以下问题:PHP sfImage类的具体用法?PHP sfImage怎么用?PHP sfImage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sfImage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: save
public function save($conn = null)
{
parent::save();
$BASE = sfConfig::get('sf_web_dir') . '/' . $this->WEB_IMAGE;
$OC = $this->getObject();
if ($OC instanceof Cicles) {
$I = $OC->getImatge();
if (!empty($I) && file_exists($BASE . $I)) {
$img = new sfImage($BASE . $I, 'image/jpg');
$img->resize(100, 100);
$nom = $OC->getCicleid() . '.jpg';
$img->saveAs($BASE . $nom);
if ($I != $nom) {
unlink($BASE . $I);
}
$OC->setImatge($nom)->save();
}
$P = $OC->getPdf();
if (!empty($P) && file_exists($BASE . $P)) {
$nom = $OC->getCicleid() . '.pdf';
rename($BASE . $P, $BASE . $nom);
if ($P != $nom) {
unlink($BASE . $P);
}
$OC->setPdf($nom)->save();
}
}
}
开发者ID:nagiro,项目名称:intra,代码行数:28,代码来源:CiclesForm.class.php
示例2: save
public function save($conn = null)
{
parent::save();
$BASE = $this->URL_IMAGE;
$ON = $this->getObject();
if ($ON instanceof Noticies) {
$I = $ON->getImatge();
if (!empty($I) && file_exists($BASE . $I)) {
$img = new sfImage($BASE . $I, 'image/jpg');
$img->resize(100, 100);
$nom = $ON->getIdnoticia() . '.jpg';
$img->saveAs($BASE . $nom);
if ($I != $nom) {
unlink($BASE . $I);
}
$ON->setImatge($nom)->save();
}
$P = $ON->getAdjunt();
if (!empty($P) && file_exists($BASE . $P)) {
$nom = $ON->getIdnoticia() . '.pdf';
rename($BASE . $P, $BASE . $nom);
if ($I != $nom) {
unlink($BASE . $P);
}
$ON->setAdjunt($nom)->save();
}
}
}
开发者ID:nagiro,项目名称:intra,代码行数:28,代码来源:NoticiesForm.class.php
示例3: createMask
protected function createMask(sfImage $image, $w, $h)
{
// Create a mask png image of the area you want in the circle/ellipse (a 'magicpink' image with a black shape on it, with black set to the colour of alpha transparency) - $mask
$mask = $image->getAdapter()->getTransparentImage($w, $h);
// Set the masking colours
if (false === $this->getColor() || 'image/png' == $image->getMIMEType()) {
$mask_black = imagecolorallocate($mask, 0, 0, 0);
} else {
$mask_black = $image->getAdapter()->getColorByHex($mask, $this->getColor());
}
// Cannot use white as transparent mask if color is set to white
if ($this->getColor() === '#FFFFFF' || $this->getColor() === false) {
$mask_transparent = imagecolorallocate($mask, 255, 0, 0);
} else {
$mask_color = imagecolorsforindex($mask, imagecolorat($image->getAdapter()->getHolder(), 0, 0));
$mask_transparent = imagecolorallocate($mask, $mask_color['red'], $mask_color['green'], $mask_color['blue']);
}
imagecolortransparent($mask, $mask_transparent);
imagefill($mask, 0, 0, $mask_black);
// Draw the rounded rectangle for the mask
$this->imagefillroundedrect($mask, 0, 0, $w, $h, $this->getRadius(), $mask_transparent);
$mask_image = clone $image;
$mask_image->getAdapter()->setHolder($mask);
return $mask_image;
}
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:25,代码来源:sfImageRoundedCornersGD.class.php
示例4: updateObject
public function updateObject($values = null)
{
$object = parent::updateObject($values);
if ($av = $object->getAvatar('raw')) {
$tmp_name = sfConfig::get('sf_upload_dir') . '/avatars/' . $av;
if (!file_exists($tmp_name)) {
return $object;
}
// Génération miniature 50x50
$mini = new sfImage($tmp_name);
$mini->thumbnail(50, 50, 'inflate');
$mini->setQuality(80);
$mini->saveAs(sfConfig::get('sf_upload_dir') . '/avatars/50x50/' . $av);
// Génération miniature 32x32
$mini = new sfImage($tmp_name);
$mini->thumbnail(32, 32, 'inflate');
$mini->setQuality(80);
$mini->saveAs(sfConfig::get('sf_upload_dir') . '/avatars/32x32/' . $av);
// Génération miniature 16x16
$mini = new sfImage($tmp_name);
$mini->thumbnail(16, 16, 'inflate');
$mini->setQuality(80);
$mini->saveAs(sfConfig::get('sf_upload_dir') . '/avatars/16x16/' . $av);
// On supprime le fichier original
unlink($tmp_name);
}
return $object;
}
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:28,代码来源:Avatar.class.php
示例5: transform
/**
* Apply the transform to the sfImage object.
*
* @param sfImage
* @return sfImage
*/
protected function transform(sfImage $image)
{
$resource = $image->getAdapter()->getHolder();
$resourcex = imagesx($resource);
$resourcey = imagesy($resource);
for ($x = 0; $x < $resourcex; ++$x) {
for ($y = 0; $y < $resourcey; ++$y) {
$distx = rand(-$this->scatter_factor, $this->scatter_factor);
$disty = rand(-$this->scatter_factor, $this->scatter_factor);
// keep inside the image boundaries
if ($x + $distx >= $resourcex) {
continue;
}
if ($x + $distx < 0) {
continue;
}
if ($y + $disty >= $resourcey) {
continue;
}
if ($y + $disty < 0) {
continue;
}
$oldcol = imagecolorat($resource, $x, $y);
$newcol = imagecolorat($resource, $x + $distx, $y + $disty);
imagesetpixel($resource, $x, $y, $newcol);
imagesetpixel($resource, $x + $distx, $y + $disty, $oldcol);
}
}
return $image;
}
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:36,代码来源:sfImageScatterGD.class.php
示例6: save
public function save($conn = null)
{
parent::save();
$OR = $this->getObject();
if (!is_null($this['Categories']->getValue())) {
$OR->setCategories(implode('@', $this['Categories']->getValue()));
}
$BASE = sfConfig::get('sf_web_dir') . '/' . $this->WEB_IMATGE;
if ($OR instanceof Activitats) {
$I = $OR->getImatge();
if (!empty($I) && file_exists($BASE . $I)) {
$img = new sfImage($BASE . $I, 'image/jpg');
$img->resize(150, 150);
$nom = $OR->getActivitatid() . '.jpg';
$img->saveAs($BASE . $nom);
if ($I != $nom) {
unlink($BASE . $I);
}
$OR->setImatge($nom);
}
$P = $OR->getPdf();
if (!empty($P) && file_exists($BASE . $P)) {
$nom = $OR->getActivitatid() . '.pdf';
rename($BASE . $P, $BASE . $nom);
if ($I != $nom) {
unlink($BASE . $P);
}
$OR->setPdf($nom);
}
}
$OR->save();
}
开发者ID:nagiro,项目名称:intra,代码行数:32,代码来源:ActivitatsTextosForm.class.php
示例7: transform
/**
* Apply the transform to the sfImage object.
*
* @param integer
* @return sfImage
*/
protected function transform(sfImage $image)
{
// Check we have a valid image resource
$resource = $image->getAdapter()->getHolder();
$resource->flopImage();
return $image;
}
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:13,代码来源:sfImageMirrorImageMagick.class.php
示例8: image_cache_tag
function image_cache_tag($route, $format, $path, $image, $alt = null)
{
$_formats = sfConfig::get('imagecache_formats');
$_format = $_formats[$format];
if (!isset($_format)) {
throw new RuntimeException('Format not found');
}
$real_file_path = sfConfig::get('sf_upload_dir') . '/' . $path . '/' . $image;
if (file_exists($real_file_path)) {
$cache_file_path = sfConfig::get('sf_upload_dir') . '/cache/' . $format . '/' . $path . '/' . $image;
$is_cached_file = file_exists($cache_file_path);
$options = array('path' => $format . '/' . $path . '/' . $image);
$url = urldecode(url_for($route, $options));
if ($is_cached_file) {
$cached_image = new sfImage($cache_file_path);
$width = $cached_image->getWidth();
$height = $cached_image->getHeight();
return image_tag($url, array('size' => $width . 'x' . $height, 'alt' => $alt));
} else {
return image_tag($url, array('alt' => $alt));
}
} else {
return '';
}
}
开发者ID:GrifiS,项目名称:SyrexCMS,代码行数:25,代码来源:ImageCacheHelper.php
示例9: execute
/**
* Apply the transform to the sfImage object.
*
* @param sfImage
* @return sfImage
*/
public function execute(sfImage $image)
{
// Check we have a valid image holder
if (false === $image->getAdapter()->hasHolder()) {
throw new sfImageTransformException(sprintf('Cannot perform transform: %s invalid image resource', get_class($this)));
}
return $this->transform($image);
}
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:14,代码来源:sfImageTransformAbstract.class.php
示例10: transform
/**
* Apply the transform to the sfImage object.
*
* @param sfImage
* @return sfImage
*/
protected function transform(sfImage $image)
{
$resource = $image->getAdapter()->getHolder();
$x = imagesx($resource);
$y = imagesy($resource);
$image->resize(round($x * $this->scale), round($y * $this->scale));
return $image;
}
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:14,代码来源:sfImageScaleGD.class.php
示例11: transform
/**
* Apply the transform to the sfImage object.
*
* @param sfImage
* @return sfImage
*/
protected function transform(sfImage $image)
{
$resource = $image->getAdapter()->getHolder();
$x = $resource->getImageWidth();
$y = $resource->getImageHeight();
$image->resize(round($x * $this->scale), round($y * $this->scale));
return $image;
}
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:14,代码来源:sfImageScaleImageMagick.class.php
示例12: save
public function save(Doctrine_Connection $conn = null)
{
$slug = Magic::slugify($this->getTitle());
if ($this->isNew()) {
$i = 0;
do {
$i++;
$q = Doctrine::getTable('Event')->findOneBySlug($slug);
if (!$q) {
break;
} else {
$slug = Magic::slugify($this->getTitle());
$slug .= $i;
}
} while ($i);
$this->setSlug($slug);
} elseif ($slug != $this->getSlug()) {
$i = 0;
do {
$i++;
$q = Doctrine::getTable('Event')->findOneBySlug($slug);
if (!$q) {
$this->setSlug($slug);
break;
} else {
if ($slug == $this->getSlug()) {
break;
} else {
$slug = Magic::slugify($this->getTitle());
$slug .= $i;
}
}
} while ($i);
}
if ($this->get('sticky') == 'no') {
$this->set('sticky', 1000);
}
parent::save($conn);
$config = sfConfig::get('app_sfDoctrineJCroppablePlugin_models');
$dir = sfConfig::get('sf_upload_dir') . DIRECTORY_SEPARATOR . $config['Events']['directory'];
$image = $this->getImageSrc('mugshot', 'original');
if ($this->getMugshot() != '') {
$arr_filename = explode('.', $this->getMugshot());
$filename = $arr_filename[0] . '_original.' . $arr_filename[1];
$file = $dir . DIRECTORY_SEPARATOR . $filename;
if (is_file($file)) {
$dims = array(array('w' => 950, 'h' => 534), array('w' => 720, 'h' => 405), array('w' => 250, 'h' => 141));
$size = getimagesize($file);
$img = new sfImage($file, $size['mime']);
foreach ($dims as $dim) {
$img->resize($dim['w'], $dim['h']);
$img->setQuality(90);
$img->saveAs($dir . '/' . $arr_filename[0] . '_' . $dim['w'] . 'x' . $dim['h'] . '.jpg');
}
}
}
}
开发者ID:Gula,项目名称:magic,代码行数:57,代码来源:Event.class.php
示例13: transform
/**
* Apply the transform to the sfImage object.
*
* @param sfImage
* @return sfImage
*/
protected function transform(sfImage $image)
{
$resource = $image->getAdapter()->getHolder();
if (function_exists('imagefilter')) {
imagefilter($resource, IMG_FILTER_NEGATE);
} else {
throw new sfImageTransformException(sprintf('Cannot perform transform, GD does not support imagefilter '));
}
return $image;
}
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:16,代码来源:sfImageNegateGD.class.php
示例14: save
public function save($conn = null)
{
$OPromocions = $this->getObject();
PromocionsPeer::gestionaOrdre($this->getValue('Ordre'), $OPromocions->getOrdre(), $this->getOption('IDS'));
parent::save();
$nom = $OPromocions->getExtensio();
if (!empty($nom)) {
$img = new sfImage($this->URL . $nom, 'image/jpg');
$img->resize(171, 63)->saveAs($this->URL . $nom);
}
}
开发者ID:nagiro,项目名称:intra,代码行数:11,代码来源:PromocionsForm.class.php
示例15: transform
/**
* Apply the transform to the sfImage object.
*
* @param sfImage
* @return sfImage
*/
protected function transform(sfImage $image)
{
$resource = $image->getAdapter()->getHolder();
// Set the defined color as transparent
if ($this->color !== '') {
$color = $image->getAdapter()->getColorByHex($resource, $this->color);
} else {
$color = imagecolorat($resource, 0, 0);
}
imagecolortransparent($resource, $color);
return $image;
}
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:18,代码来源:sfImageTransparencyGD.class.php
示例16: transform
/**
* Apply the transform to the sfImage object.
*
* @param sfImage
* @return sfImage
*/
protected function transform(sfImage $image)
{
$resource = $image->getAdapter()->getHolder();
$resourcex = imagesx($resource);
$resourcey = imagesy($resource);
for ($x = 0; $x < $resourcex; $x += $this->block_size) {
for ($y = 0; $y < $resourcey; $y += $this->block_size) {
$rgb = imagecolorat($resource, $x, $y);
imagefilledrectangle($resource, $x, $y, $x + $this->block_size - 1, $y + $this->block_size - 1, $rgb);
}
}
return $image;
}
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:19,代码来源:sfImagePixelizeGD.class.php
示例17: save
public function save(Doctrine_Connection $conn = null)
{
$slug = Magic::slugify($this->getTitle());
if ($this->isNew()) {
$i = 0;
do {
$i++;
$q = Doctrine::getTable('Page')->findOneBySlug($slug);
if (!$q) {
break;
} else {
$slug = Magic::slugify($this->getTitle());
$slug .= $i;
}
} while ($i);
$this->setSlug($slug);
} elseif ($slug != $this->getSlug()) {
$i = 0;
do {
$i++;
$q = Doctrine::getTable('Page')->findOneBySlug($slug);
if (!$q) {
$this->setSlug($slug);
break;
} else {
if ($slug == $this->getSlug()) {
break;
} else {
$slug = Magic::slugify($this->getTitle());
$slug .= $i;
}
}
} while ($i);
}
parent::save($conn);
// generamos thumbnails
$file = sfConfig::get('sf_upload_dir') . '/pictures/' . $this->getPicture();
if (is_file($file)) {
$dims = array(array('w' => 950, 'h' => 534), array('w' => 720, 'h' => 405), array('w' => 250, 'h' => 141), array('w' => 60, 'h' => 60));
$size = getimagesize($file);
$img = new sfImage($file, $size['mime']);
if (!is_dir(sfConfig::get('sf_upload_dir') . '/' . $this->get('id'))) {
mkdir(sfConfig::get('sf_upload_dir') . '/' . $this->get('id'), 0777);
}
foreach ($dims as $dim) {
$img->thumbnail($dim['w'], $dim['h']);
$img->setQuality(90);
$img->saveAs(sfConfig::get('sf_upload_dir') . '/' . $this->get('id') . '/img_' . $this->get('id') . '_' . $dim['w'] . 'x' . $dim['h'] . '.jpg');
}
}
}
开发者ID:Gula,项目名称:magic,代码行数:51,代码来源:Page.class.php
示例18: transform
/**
* Apply the transform to the sfImage object.
*
* @param sfImage
* @return sfImage
*/
protected function transform(sfImage $image)
{
// No need to do anything
if ($this->angle == 0) {
return $image;
}
$resource = $image->getAdapter()->getHolder();
// By default use the background of the top left corner
if ($this->background === '') {
$this->background = $resource->getImagePixelColor(0, 0);
}
$resource->rotateImage($this->background, $this->angle);
return $image;
}
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:20,代码来源:sfImageRotateImageMagick.class.php
示例19: transform
/**
* Apply the transform to the sfImage object.
*
* @param sfImage
* @return sfImage
*/
protected function transform(sfImage $image)
{
$resource = $image->getAdapter()->getHolder();
// By default use the background of the top left corner
if (is_null($this->background)) {
$this->background = $resource->getImagePixelColor(0, 0);
$background = $this->background;
} else {
$background = new ImagickPixel();
$background->setColor($this->background);
}
$resource->setBackgroundColor($background);
$resource->trimImage($this->fuzz);
return $image;
}
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:21,代码来源:sfImageTrimImageMagick.class.php
示例20: transform
/**
* Apply the transform to the sfImage object.
*
* @param integer
* @return sfImage
*/
protected function transform(sfImage $image)
{
$resource = $image->getAdapter()->getHolder();
$x = imagesx($resource);
$y = imagesy($resource);
$dest_resource = $image->getAdapter()->getTransparentImage($x, $y);
for ($h = 0; $h < $y; $h++) {
imagecopy($dest_resource, $resource, 0, $h, 0, $y - $h - 1, $x, 1);
}
// Tidy up
imagedestroy($resource);
// Replace old image with flipped version
$image->getAdapter()->setHolder($dest_resource);
return $image;
}
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:21,代码来源:sfImageFlipGD.class.php
注:本文中的sfImage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论