Matt Thomson

WideImage Library Plugin for Joomla 1.6

Hi All,

I have been using the Wideimage (http://wideimage.sourceforge.net/) library in my gallery extension for the last couple of versions. I have spent some time of the last 2 years the making my own image functions, and experimenting with other libraries, and this is the best I have found.

Essentially it is a small PHP5 library (160KB) that is a wrapper PHP GD functions. GD works well for Joomla extensions, as although ImageMagick has some benefits, it can be difficult to set up and use, especially on shared servers. GD usually works out of the box on any PHP installation.

The library does resizing, cropping, rotating, watermarking (full list is here http://wideimage.sourceforge.net/documentation/manipulating-images/), and it works well with transparent pngs and gifs.

While making the Joomla 1.6 version of my extension, I have taken wideimage out of the component, and put it into a library plugin. The hope is that it can become a library for 3rd party developers to use and improve, instead of us all using our own image functions inside our extensions.

Currently the plugin is just the wideimage library, with the defined('_JEXEC'), index.html, and support for JFile writing added in.

Immediate goals are to add in JError support and JText language support.

More long term goals are to add in more operations like rounded corners. The library keeps all its operations in separate classes, so to add in a new operation you just drop in the file.

I'm not sure if Joomla needs an image library in the core, as Joomla itself does not do any image manipulation. As it is us 3pd's that do the image manipulation, I think it makes sense to have a library maintained and improved by us.

I also hear the media manager is due for a big upgrade in Joomla 1.7 which may include an image library. I think this is great, but I also think there needs to be a solution for Joomla 1.6 developers now, and the media manager could build on this.

Using the plugin is as easy as:

jimport('joomla.filesystem.file');

if(!jimport('wideimage.WideImage') ){
return JError::raiseWarning(404, 'WideImage Library Not Found');
}

$sourceImage = JPATH_SITE.DS.'images'.DS.'test_image.jpg';
$resizedImage = JPATH_SITE.DS.'images'.DS.'resized_image.jpg';

//resize an image
WideImage::load($sourceImage)->resize(200, 150)->saveToFile($resizedImage);

//resize then crop
WideImage::load($sourceImage)->resize(200, 100)->crop(50, 50, 30, 20)->saveToFile($resizedImage);

//watermark with 50% transparancy
$image = WideImage::load($sourceImage);
$watermark = WideImage::load($source_to_watermark_image);
$image->merge($watermark,"right", "bottom", 50);


More examples and docs are on the wideimage site:
http://wideimage.sourceforge.net/documentation/

If others have interest in the project, I can make a Joomlacode project, and google group for development discussion.

[EDIT]Please see http://www.alltogetherasawhole.org/profiles/blogs/image-library-for... for latest info on this project and a download link[EDIT]


Views: 127

Amy Stephen Comment by Amy Stephen on June 16, 2010 at 11:03pm
Dude - you rock!!! Thanks so much!
Marco Barbosa Comment by Marco Barbosa on June 17, 2010 at 3:39am
Man this is awesome!

I will check it out. I want to build a slideshow module but with resizing and so on..
and this might be it :D
Ben Borges Comment by Ben Borges on June 17, 2010 at 6:52am
this is great !
Troy Thomas Hall Comment by Troy Thomas Hall on June 17, 2010 at 3:37pm
is it possible to have the saved file always as .jpg for example when it comes in as .bmp? This would save me TONS of room on my drive
Matt Thomson Comment by Matt Thomson on June 17, 2010 at 3:42pm
Yes, the wideimage docs have a lot of info on this:

http://wideimage.sourceforge.net/documentation/saving-images/
Matt Thomson Comment by Matt Thomson on June 17, 2010 at 3:45pm
Also, Thanks to Gašper for making this great library, all I did was package it.
Troy Thomas Hall Comment by Troy Thomas Hall on June 19, 2010 at 5:26am
thats awesome, I can easily see this becoming a "defacto" switch inside of J! *HINT* @ JDEV :P
Arunas Mazeika Comment by Arunas Mazeika on July 29, 2010 at 7:39am
Hey Matt, I think that this is an interesting idea.

GD is not very friendly when it comes to perform some simple and frequently used tasks, like cropping, watermarking, resizing while keeping aspect, etc. I developed my own set methods for performing those on my apps. Imagick on the other hand, very easy and straightforward, but as you said, not available on every server.

Anyways, I would like discuss this a little bit more with you if you don't mind. I think that something good may come out of this.
Matt Thomson Comment by Matt Thomson on July 29, 2010 at 4:14pm
Sure, unless the discussion is a private matter (you can p.m me on this site for this), I think it is better to keep any discussion in this thread, where anyone can view/comment on it. What do you want to discuss.
Arunas Mazeika Comment by Arunas Mazeika on July 29, 2010 at 4:33pm
No nothing private :), at least for now. You talked about perhaps starting a little project. Just wanted to let you know that I'm in if you agree.

Overall I think that an extremely easy to use image processing library for Joomla with some JFile integration, etc. would be useful. I'm thinking right now on a facade if you would like to keep the wideimage (I haven't seen it in detail though), which might be good instead of reinventing the wheel.

Comment

You need to be a member of All Together, As A Whole to add comments!

Join All Together, As A Whole

Badge

Loading…

© 2012   Created by Amy Stephen.

Badges  |  Report an Issue  |  Terms of Service