Hi All,

I have started a gd image library project for Joomla 1.6 here:

http://code.google.com/p/gd-image-library-for-joomla/

Originally the project was a wrapper to wideimage:
http://www.alltogetherasawhole.org/profiles/blogs/wideimage-library...

But I figured it would be better to do a mini fork of wideimage, and customise it to fit the needs of Joomla.

The library does what wideimage does, minus a few advanced things like ApplyConvolution. It also writes with the Joomla ftp layer if turned on and uses JError to raise messages. The messages are kept in a language ini file, so the library is translatable using Joomla's langauge system.

The library supports jpegs, gifs, pngs (transparancies ok), and will do Resize, Crop, Rotate, Watermark with image, Watermark with text, Rounded corners, Mirror, Flip, Greyscale, Applymask, CorrectGamma.

Using the library is as easy as:

if(!jimport('gdimage.GdImage') ){
return JError::raiseError(500, 'Image Library Not Found');
}

$sourcePath
= JPATH_SITE.DS.'images'.DS.'tree.jpg';
$resizedPath
= JPATH_SITE.DS.'images'.DS.'tree_resized.jpg';
GDImage::load($sourcePath)->resize(300, 400)->saveToFile($resizedPath);

More example are here:
http://code.google.com/p/gd-image-library-for-joomla/wiki/codeexamples

I will be bug doing testing and bug fixing over the next week.
If you want to contribute or suggest features let me know.




Views: 86

ssnobben Comment by ssnobben on August 25, 2010 at 4:44am
Hi Matt,

I have not read what you are doing b u t one suggestions though. Would it be possible to make the image gallery work with ACL and core so users have their own private image folder something that JCE does with this hack?

JCE Personal Image Folders
It has long been an issue with site members who had access to image folders on the server when creating and posting articles and content items. The use of this creates a user specific images folder based on their user ID. All of these folders reside in the media folder. Each users folder will show as "root" when they view their images. Each user can also create private sub-folders within their personal root folder for organizing their images. They can no longer navigate folders on the server once all of this is in place. This improves your site security and protects your other members and server images as they are no longer accessible to each user. The site administrator still has access to all of the images and his use of JCE images is not effected.

http://www.joomlacache.com/free-extensions/jce-personal-image-folde...
Matt Thomson Comment by Matt Thomson on August 25, 2010 at 4:53am
Hi ssnobben,

I think a solution like that would be best solved on an extension application level (such as a component), rather than on a library level.

The goal of the image library is to make an easy way to do image manipulation, but to not be specific about how the image functions are used. That way all different applications can use it how they want.

Generally speaking, I think it is best to have libraries that do the Generic functions like check ACL, make/ browse folders, do image functions, and then have components that call up these functions in different ways to achieve (an infinite amount of) different goals.
ssnobben Comment by ssnobben on August 25, 2010 at 5:15am
Matt,

thanks for your comments and explanation. Question is how this could be solved and implemented?

Rgds
Matt Thomson Comment by Matt Thomson on August 25, 2010 at 5:51am
I think that is a very big question, my guess is that any solution would involve at least a few dozen pages of php, I don't think it is something I can comment one in one blog post.

I think ultimately that problem is one for extension developers to solve.
Amy Stephen Comment by Amy Stephen on August 28, 2010 at 3:45pm
Matt - thanks for your work on this. Was looking at the examples and it appears they have been deleted. Hope to look at it when the code and examples return. Appreciate it!
Robert Vining Comment by Robert Vining on August 28, 2010 at 10:07pm
Hey Amy, I found a copy of what was there in the revisions... just for reference.

http://code.google.com/p/gd-image-library-for-joomla/source/browse/...
Matt Thomson Comment by Matt Thomson on September 22, 2010 at 12:08am
Andrea Tarr Comment by Andrea Tarr on October 19, 2010 at 10:25am
I used the earlier version of your wide image library on a project and it was great. The one issue I have is that it almost doubles the size of the image when I add an image watermark. For instance if the original photo is 138k, the new one is 231k. The watermark is only 2k. Since I have 20,000 photos on the site this is an issue for storage as well as display.

Do you know if this is expected behavior for the wide image library? Are they keeping the original and adding the altered version to it?

I see that you've gone to a fork rather than a wrapper which I'll be checking out, though I don't know that this problem would be affected by that.

Thanks for any insights!

Andy

P.S. The updated link for the CodeExamples doesn't exist either. Here's a link to the first wiki doc article where you can access the other docs:

http://code.google.com/p/gd-image-library-for-joomla/wiki/Importing...
Matt Thomson Comment by Matt Thomson on October 19, 2010 at 3:21pm
Hi, My guess is this is unrelated to the watermarking, bit more related to the way the php GD library works.

When you save a JPEG, you can choose a quality paramater, I forgot to put this in the docs. On the http://code.google.com/p/gd-image-library-for-joomla/wiki/SavingImages page, there should be $image->saveToFile($savePath, 80); as an example as well. If you are saving a jpeg, and don't put in 80, the library will default to 100 for jpeg quality.

In gd langauge, 100 doesn't mean 'the same filesize as the original', it means more like 'put in x amount of detail'. So when you save an image with 100% quality, it can end up having a bigger size than the original.

In my gallery code, I use:
if( preg_match("/jp/i", $fileExt) )
{
$image->saveToFile($destFile, $quality);
}
else
{
$image->saveToFile($destFile);
}

I'll add some more info to the docs about this.

Can you try using 80, and seeing if the filesize is better.
Andrea Tarr Comment by Andrea Tarr on October 19, 2010 at 3:34pm
I was rummaging around in the code and came across the compression parameter in the php comments so I tried using it. I didn't realize that 100 didn't mean don't compress so that explains some of the results I got. I'm just finishing some tests but it looks like something in the mid 90's will actually leave me at the same size -- 99 was half again as large and 90 was a quarter smaller and 70 was a third the size.

I upgraded my local site to your new version very easily which was convenient, too.

Thanks for the help. I like it so much better when I can understand why it's doing something.

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