sfImageTransformPlugin – released

October 15, 2008 · Posted in Configuration, Freelance, Installation, Networking, Plugins, Symfony 

Stuart Lowes has released sfImageTransformPlugin 0.1.0 for Symfony. This plugin is for manipulating images using the GD or ImageMagick libraries.

A simple to use and flexible image manipulation symfony plugin. The plugin allows you to perform “transforms” on an image. A transform maybe simple like a resizing or mirroring or more complex like overlays and pixelizing. The transforms can be chained together or applied individually. New transforms can be simple created by extending the sfImageTranform abstract class.

Download

http://plugins.symfony-project.org/sfImageTransformPlugin

Plugin page

http://www.symfony-project.org/plugins/sfImageTransformPlugin

Examples

Starting with the original image:-

sfImageTransform

Here is an example of a transform that:-

  • scales ‘logo.png’ by 50%
public function executeDemo1()
{
 $img = new sfImage(sfConfig::get('sf_upload_dir') . DIRECTORY_SEPARATOR . 'logo.png', 'image/png');
 $response = $this->getResponse();
 $response->setContentType($img->getMIMEType());

 $img->scale(0.5);

 $response->setContent($img);

 return sfView::NONE;
}

Result:-

Here is an example of a transform that:-

  • flood fill’s ‘logo.png’ at ‘x100,y170′ with #000000
  • scales by 50%
  • rotate by 120%
  • draw a rectancle of 5 pixels around edge and colour it #00FF00
  • write the text “bathcamp 2008″ at ‘x10,y10′ 10px Verdana coloured #FF9900
public function executeDemo5()
{
 $img = new sfImage(sfConfig::get('sf_upload_dir') . DIRECTORY_SEPARATOR . 'logo.png', 'image/png');
 $response = $this->getResponse();
 $response->setContentType($img->getMIMEType());

 $img->fill(100,170)->scale(0.5)->rotate(120)->rectangle(1, 1, $img->getWidth() - 1, $img->getHeight() - 5, 5, '#00FF00')->text('bathcamp 2008', 10, 10, 10, 'Verdana', '#FF9900');

 $response->setContent($img);

 return sfView::NONE;
}

Result


Stunami has provided a collection of transforms for the GD and ImageMagick libraries.

Comments

One Response to “sfImageTransformPlugin – released”

  1. [...] sfImageTransformPlugin – released [...]

Leave a Reply




  • Pactpub recommended

      Get the Flash Player to see the slideshow.