To do:
Zend Framework: Zend_Image Component Proposal
| Proposed Component Name | Zend_Image |
|---|---|
| Developer Notes | http://framework.zend.com/wiki/display/ZFDEV/Zend_Image |
| Proposers | Dolf Schimmel Marcin Lulek |
| Zend Liaison | TBD |
| Revision | 1.0 - 1 Oct 2008: Initial Draft. 1.1 - 16 Oct 2008: Finished proposal (ex. class skeletons) (wiki revision: 8) |
Table of Contents
1. Overview
Zend_image is a component used for handling images.
Marcin Lulek a.k.a. Ergo2 has written an image component on which this proposal and initial codebase is based. His component does however miss an object oriented interface, and therefore it has been decided to fully refactor it. As for there is already a suitable codebase (preview of its functionality can be found here ; http://webreactor.eu/image/ ), offers of components written by others are unnecessary (appreciated though).
2. References
3. Component Requirements, Constraints, and Acceptance Criteria
- This component will be able to resize images.
- This component will be able to rotate images.
- This component will be able to print a watermarks on images.
- This component will be able to draw; eclipses, arcs, lines and polygons
- This component will be able to convert images (I.E. from jpeg to bmp).
- This component will be able to apply several filters, as well as adjust contrast etc.
4. Dependencies on Other Framework Components
- GD or Imagemagick
- Zend_Exception
5. Theory of Operation
An instance of Zend_Image will have one image resource by default. The path of this image can be specified when constructing it. It can however also be loaded from a file or string, or be created by Zend_Image itself. Once a resource has been loaded, the actions on the image can be performed, like cropping, resizing, rotating, etc.
By default Zend_Image will support two adapters, namely Zend_Image_Adapter_Gd and Zend_Image_Adapter_Imagemagick.
6. Milestones / Tasks
- Milestone 1: Proposal finished
- Milestone 2: Development of prototype started
- Milestone 3: Proposal approved
- Milestone 4: Working prototype checked into the incubator.
- Milestone 5: Unit tests exist, work, and are checked into SVN.
- Milestone 6: Documentation exists.
7. Class Index
- Zend_Image
- Zend_Image_Adapter_Abstract
- Zend_Image_Adapter_Gd
- Zend_Image_Adapter_Imagemagick
- Zend_Image_Object_Line
- Zend_Image_Object_Ellipse
- Zend_Image_Object_Circle
- Zend_Image_Object_Arch
- Zend_Image_Object_Text
- Zend_Image_Object_Polygon
- Zend_Image_Object_Filter
- Zend_Image_Action_AdjustAlpha
- Zend_Image_Action_Resize
- Zend_Image_Action_Blend
- Zend_Image_Action_Rotate
- Zend_Image_Action_Brightness
- Zend_Image_Action_Contrast
- Zend_Image_Action_Colorize
- Zend_Image_ObjectInterface_Line
- Zend_Image_ObjectInterface_Ellipse
- Zend_Image_ObjectInterface_Circle
- Zend_Image_ObjectInterface_Arch
- Zend_Image_ObjectInterface_Text
- Zend_Image_ObjectInterface_Polygon
- Zend_Image_ObjectInterface_Filter
- Zend_Image_ActionInterface_AdjustAlpha
- Zend_Image_ActionInterface_Resize
- Zend_Image_ActionInterface_Blend
- Zend_Image_ActionInterface_Rotate
- Zend_Image_ActionInterface_Brightness
- Zend_Image_ActionInterface_Contrast
- Zend_Image_ActionInterface_Colorize
- Zend_Image_Adapter_Gd_Object_Line
- Zend_Image_Adapter_Gd_Object_Ellipse
- Zend_Image_Adapter_Gd_Object_Circle
- Zend_Image_Adapter_Gd_Object_Arch
- Zend_Image_Adapter_Gd_Object_Text
- Zend_Image_Adapter_Gd_Object_Polygon
- Zend_Image_Adapter_Gd_Object_Filter
- Zend_Image_Adapter_Imagemagick_Object_Line
- Zend_Image_Adapter_Imagemagick_Object_Ellipse
- Zend_Image_Adapter_Imagemagick_Object_Circle
- Zend_Image_Adapter_Imagemagick_Object_Arch
- Zend_Image_Adapter_Imagemagick_Object_Text
- Zend_Image_Adapter_Imagemagick_Object_Polygon
- Zend_Image_Adapter_Imagemagick_Object_Filter
- Zend_Image_Adapter_Gd_Action_AdjustAlpha
- Zend_Image_Adapter_Gd_Action_Resize
- Zend_Image_Adapter_Gd_Action_Blend
- Zend_Image_Adapter_Gd_Action_Rotate
- Zend_Image_Adapter_Gd_Action_Brightness
- Zend_Image_Adapter_Gd_Action_ActionInterface_Contrast
- Zend_Image_Adapter_Gd_Action_Colorize
- Zend_Image_Adapter_Imagemagick_Action_AdjustAlpha
- Zend_Image_Adapter_Imagemagick_Action_Resize
- Zend_Image_Adapter_Imagemagick_Action_Blend
- Zend_Image_Adapter_Imagemagick_Action_Rotate
- Zend_Image_Adapter_Imagemagick_Action_Brightness
- Zend_Image_Adapter_Imagemagick_Action_Contrast
- Zend_Image_Adapter_Imagemagick_Action_Colorize
8. Use Cases
| UC-01 |
|---|
$options = array('thickness' => 5,
'filled' => true,
'startX' => 10,
'startY' => 15,
'endX' => 50,
'endY' => 125);
$image = new Zend_Image('/path/to/image.png');
$image->draw(Zend_Image::LINE,$options);
$image->save();
| UC-02 |
|---|
$line = new Zend_Image_Line();
$line->from(10,15)
->to(50,125)
->setFilled(true);
$image = new Zend_Image('/path/to/image.png'); // Autodetect adapter to use
$image->draw($line);
$image->save();
| UC-03 |
|---|
$chain = new Zend_Image_Chain();
$line = new Zend_Image_Object_Line();
$line(10,15,50,125)->setFilled(true);
$chain->add($line);
$image = new Zend_Image('/path/to/image.png',Zend_Image::GD);
$image->perform($chain);
$image->save();
| UC-04 |
|---|
// Create new image;
$image = new Zend_Image();
$image->create(50,20); // X, Y size;
file_put_contents('/path/to/image.png',$image->get()); //
$image->save('/path/to/image.png'); // Both lines do the same
9. Class Skeletons
+1 for Helgi
I think the work you made so far could be an excellent base for such a Zend_Image component. I'd be really interested in contributing making it become an official ZF component.
Dolf, Helgi, please don't hesitate to get in touch!
there is work undertaken for zend image by me - ie. there is a prototype that works with gd2 and has cosidrable functionality.
Helgi Hrafn Halldórsson - your proposal wont get past evaluation , there were 3 proposals so far and all were rejected they were all similar to what you did.
http://webreactor.eu/image/ - here are some results from the prototype ive sent to Dolf Schimmel, it still lacks the object oriented interface - we discussed that and it will appear in the proposal probably soon, we have an idea how it should look like.
LOL, how many people have written something like this since Zend Framework doesn't have it? I myself wrote a component similar to Heigi's a couple years ago. In fact, the method signatures look so similar our code is probably nearly identical! Although this was before IMagick was updated, so it used ImageMagick's own MagickWand for PHP extension.
ZF Home Page
Code Browser
Wiki Dashboard
I have created something we use here at work, something that can be conisdered to look like this.
Zend_Image
Zend_Image_Adapter
Zend_Image_Exception extends Zend_Exception
Zend_Image_Adapter_Abstract
Zend_Image_Adapter_Exception extends Zend_Exception
Zend_Image_Adapter_Gd2 extends Zend_Image_Adapter_Abstract
Zend_Image_Adapter_Imagemagic extends Zend_Image_Adapter_Abstract
Where the Zend_Image_Adapter_Abstract has these functions
I can send you these files and you can use them as a guide, if you like. We have finished the Gd2 adapter, so there code to review, and more to be written in the Imagemagic adapter.
plz let me know