Author Topic: imageOptimizer  (Read 13268 times)

Ralf Hertsch

  • Guest
imageOptimizer
« on: November 23, 2008, 07:06:46 AM »
imageOptimizer parse the page_content() and replaces all images which are resized only by the <img> attributes height and width with a new, physically adapted image.

I have wrote this tool because of the experience that most editors/writers take there images directly from any digital camera and bring them with help of TinyMCE or FCKEditor a.s.o to the wished format - which results in a horrible page performance for the visitors...

imageOptimizer supports JPG, GIF and PNG (also with transparency), reduce traffic and spends your visitors fast loading and lightweight pages  8-)

Requirements

  • PHP 5.2.x
  • need the WB Addon dbConnect (attached)

Setup

After installing dbConnect and imageOptimizer edit the template(s) of your site and replace page_content(); with the following code:

Code: [Select]
if (class_exists('imageOptimizer')) {
  ob_start();
    page_content();
    $content = ob_get_contents();
  ob_end_clean();
  image_optimize($content);
}
else {
  page_content();
}

imageOptimizer register all images of your website in a database and dont change any original images. If a image should be resized/optimized imageOptimizer create a new image, place it in his directory /MEDIA/optimized_images and replace the original image with the new one. By the next call to this page imageOptimizer uses directly the image from his directory.

Known Limits / Issues

  • missing configuration interface (phpMyAdmin only)
  • at the moment you can not exclude complete pages from parsing
  • imageOptimizer does not remove no longer needed files
  • is not tested with the various image galleries, may be there will be occur some difficulties
  • missing some statistic informations
  • ...

imageOptimizer is still ALPHA but fully functionally and I use it with best results at panke.info.

Please test it, report me any problem and make suggestions for improvements.

Regards
Ralf

-- Attached files removed, please look a newer post --
« Last Edit: November 24, 2008, 08:29:46 PM by Ralf (Berlin) »

Offline marathoner

  • Posts: 495
Re: imageOptimizer
« Reply #1 on: November 23, 2008, 05:43:37 PM »
Wow...great idea! Something that should already be available in the the WYSIWYG editors! I'll test soon.

Ralf Hertsch

  • Guest
Re: imageOptimizer
« Reply #2 on: November 24, 2008, 05:06:35 AM »
Quote
Wow...great idea!
 

Thank you  8-)

Quote
Something that should already be available in the the WYSIWYG editors!

I think it's the best way to parse page_content() because you will get the output of all modules (wysiwyg, news, manual a.s.o) and not only of one editor.

Regards
Ralf

Ralf Hertsch

  • Guest
Re: imageOptimizer
« Reply #3 on: November 24, 2008, 08:28:02 PM »
Hello,

here is release 0.11 of imageOptimizer, with the following changes:

  • Bugfix: if <img> has no attributes for width and height imageOptimizer set image size to zero
  • Bugfix: imageOptimizer ignored percentual values for width and height
  • Added: imageOptimizer rewrite now the values for <img> attributes width and height if neccessary
  • Codecleanings, added comments

Error reports and suggestions for improvements welcome!

Regards
Ralf

-- Attached files removed, please look a newer post --
« Last Edit: November 27, 2008, 08:46:29 PM by Ralf (Berlin) »

Ralf Hertsch

  • Guest
Re: imageOptimizer
« Reply #4 on: November 27, 2008, 08:41:50 PM »
Hello,

release 0.12 of imageOptimizer is ready, with the following changes:

  • added: configuration control dialog
  • added: option to switch debugging mode on/off
  • added: option to encrease memory usage if necessary
  • changed php requirements to php 5.x

Important:

The initializing method for imageOptimizer has changed, please use this code in your template:

Code: [Select]
if (class_exists('imageOptimizer')) {
  ob_start();
    page_content();
    $content = ob_get_contents();
  ob_end_clean();
  image_optimize($page_id, $content);
}
else {
  page_content();
}

Because imageOptimizer is a code snippet there exists no access to the configuration via backend. To access the configuration dialog create a new page of type code and insert the following code:

Code: [Select]
if (class_exists('imageOptimizerControl')) {
  image_optimizer_control($page_id);
}
else {
  echo "imageOptimizerControl not found!";
}

You should hide this page an give access only for yourself - anyway imageOptimizer check if the accessing user is logged in and member of the group administrators otherwise imageOptimizer denies access.

Requirements:
  • PHP 5.x
  • need the WB addon dbConnect (attached)
  • need the WB addon rhTools (attached)

Error reports an suggestions for improvements welcome!

Regards
Ralf
« Last Edit: December 11, 2008, 08:59:22 AM by Ralf (Berlin) »

Offline Argos

  • Posts: 2542
  • Gender: Male
    • Argos Media
Re: imageOptimizer
« Reply #5 on: November 29, 2008, 01:15:04 AM »
Very nice and welcome function!! I can't wait for my new server in January, that has PHP5. Must do with PHP4 for a little time...
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

Ralf Hertsch

  • Guest
Re: imageOptimizer
« Reply #6 on: November 29, 2008, 05:08:18 AM »
Quote
Very nice and welcome function!!

Thank you  8-)

Quote
I can't wait for my new server in January, that has PHP5. Must do with PHP4 for a little time...

There is absolutly no chance to get imageOptimizer working with PHP4 ...  :-(

Regards
Ralf

Ralf Hertsch

  • Guest
Re: imageOptimizer
« Reply #7 on: November 30, 2008, 11:13:07 AM »
Hello,

Release 0.13 of imageOptimizer is ready.

This version is complete and should be the last beta if there are no errors...

This release add a control center with statistic informations and tools. The statistic informations are very helpful to see how effective the imageOptimizer work and how much traffic you are saving - the tools help you to keep the imageOptimizer up to date.

You need to upgrade the attached dbConnect and rhTools before upgrading the imageOptimizer.

Regards
Ralf

« Last Edit: December 11, 2008, 08:59:05 AM by Ralf (Berlin) »

Ralf Hertsch

  • Guest
Re: imageOptimizer
« Reply #8 on: November 30, 2008, 07:27:03 PM »
panke.info is a local portal, where everyone who is allowed to publish articles take his own images directly from his digital camera an place it within the articles. The following statistic screenshot shows, how effective the imageOptimizer is working:



There is nothing sugarcoated or so...

Regards
Ralf

Offline Argos

  • Posts: 2542
  • Gender: Male
    • Argos Media
Re: imageOptimizer
« Reply #9 on: November 30, 2008, 07:47:47 PM »
panke.info is a local portal, where everyone who is allowed to publish articles take his own images directly from his digital camera an place it within the articles.

Hi Ralf,

what are the image settings you use on panke.info? I only see a lot of very large images...
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

Ralf Hertsch

  • Guest
Re: imageOptimizer
« Reply #10 on: November 30, 2008, 08:02:32 PM »
Hello Argos,

Quote
what are the image settings you use on panke.info? I only see a lot of very large images...

There are also with use of the imageOptimizer some large images (i.e. at the start pages of the sub portals) - imageOptimizer dont touch images which are not resized...

Which pages/images do you mean exactly?

Edit: Ah, I have detect what you mean: it seem that the imageOptimizer have a problem with some images, for example at Flussbeschreibungen - at this page are optimized images but also a big, not optimized image: D1%20Lietzengraben%20CS.jpg. I must check the reason for this behaviour - perhaps the whitespaces...

Regards
Ralf
« Last Edit: November 30, 2008, 08:08:49 PM by Ralf (Berlin) »

Offline Argos

  • Posts: 2542
  • Gender: Male
    • Argos Media
Re: imageOptimizer
« Reply #11 on: November 30, 2008, 08:05:20 PM »
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

Ralf Hertsch

  • Guest
Re: imageOptimizer
« Reply #12 on: November 30, 2008, 08:36:02 PM »

Quote
I only visited the section "Fotografien":  http://panke.info/pages/fotografien/der-verlauf-der-panke.php?dir13=

ok - this image is a png with transparency and big, but the imageOptimizer dont touch it...  :-D

Quote
Edit: Ah, I have detect what you mean: it seem that the imageOptimizer have a problem with some images, for example at Flussbeschreibungen - at this page are optimized images but also a big, not optimized image: D1%20Lietzengraben%20CS.jpg. I must check the reason for this behaviour - perhaps the whitespaces...

This problem seems to be caused by the ownership of this image (was not accessible for the imageOptimizer).

Regards
Ralf

Offline Argos

  • Posts: 2542
  • Gender: Male
    • Argos Media
Re: imageOptimizer
« Reply #13 on: November 30, 2008, 09:02:17 PM »

Quote
I only visited the section "Fotografien":  http://panke.info/pages/fotografien/der-verlauf-der-panke.php?dir13=

ok - this image is a png with transparency and big, but the imageOptimizer dont touch it...  :-D

No no sorry, I didn't mean the single image on that page, but the complete galleries there under.
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

Ralf Hertsch

  • Guest
Re: imageOptimizer
« Reply #14 on: December 01, 2008, 05:04:16 AM »

Quote
No no sorry, I didn't mean the single image on that page, but the complete galleries there under.

Indeed the imageOptimizer should be able to optimze these pictures - at the moment I have no idea why it does not work there...

Regards
Ralf

Ralf Hertsch

  • Guest
Re: imageOptimizer
« Reply #15 on: December 01, 2008, 08:27:02 PM »
No no sorry, I didn't mean the single image on that page, but the complete galleries there under.

This problem is fixed - it was a problem with whitespaces within the image names. Please check panke.info again, hope you will not find any other problems  :-D

Regards
Ralf

Offline Argos

  • Posts: 2542
  • Gender: Male
    • Argos Media
Re: imageOptimizer
« Reply #16 on: December 01, 2008, 08:51:31 PM »
Seems to work now :-)

Great snippet!
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

Ralf Hertsch

  • Guest
Re: imageOptimizer
« Reply #17 on: December 11, 2008, 09:30:04 AM »
Hello,

I've just released imageOptimizer 0.15 (stable).

  • added: "babble mode" insert a small info bar at the end of each page to show how many images are optimized and how many traffic is saved (may be switched on/off)
  • fixed: encoding spaces within filenames

Download: imageOptimizer

Requirements: imageOptimizer needs at minimum PHP 5.x, installed rhTools 0.41 and dbConnect 0.29

After installing dbConnect, rhTools and imageOptimizer please edit the template of your website and replace page_content(); with:

Code: [Select]
if (class_exists('imageOptimizer')) {
  ob_start();
  page_content();
  $content = ob_get_contents();
  ob_end_clean();
  image_optimize($page_id, $content);
}
else {
  page_content();
}

Because the imageOptimizer is a snippet you dont have access to it by the backend. To get access to the administration of the imageOptimizer please create a new private page of type code and insert the following code:

Code: [Select]
if (class_exists('imageOptimizerControl')) {
  image_optimizer_control($page_id);
}
else {
  echo "imageOptimizerControl is not installed!";
}

The following screenshot shows the "babble mode":



This screenshot shows how effective the imageOptimizer is working at panke.info:



All error reports an suggestions for improvements are always welcome!

Regards
Ralf
« Last Edit: December 11, 2008, 11:53:39 AM by Ralf (Berlin) »

Ralf Hertsch

  • Guest
Re: imageOptimizer
« Reply #18 on: December 14, 2008, 05:53:07 PM »
Hello,

I've just released imageOptimizer 0.18 (stable).

0.18 - 2008-12-14 (STABLE)
        * fixed: ignored error while getting image size
        * fixed: try to optimize images outside the own webspace
        * fixed: debugging mode was true by default
        * added: switch to turn imageOptimizer on/off

0.17 - 2008-12-13 (STABLE)
        * added: check for the MySQL version
        * changed: changed datatypes for compatibility with MySQL 4.x

0.16 - 2008-12-11 (STABLE)
        * fixed: problem with umlauts within the title and/or alt tags

Download: imageOptimizer

Regards
Ralf

xso

  • Guest
Re: imageOptimizer breaks two other modules
« Reply #19 on: March 01, 2009, 04:54:31 PM »
After installing imageOptimizer two other modules do not work anymore:

Contactlist ( http://www.websitebakers.com/pages/modules/listings/various/contactlist.php ) gives the message blow:

Fatal error: Cannot redeclare editadressbackend() (previously declared in C:\xampp\htdocs\modules\contactlist\functions.php:35) in C:\xampp\htdocs\modules\contactlist\functions.php on line 260

and

GDpics (http://www.websitebakers.com/pages/modules/image-galleries/gdpics-image-gallery.php?searchresult=1&sstring=gdpics)

gives only blank pages.


Uninstalling ImageOptimizer makes them working again.

regards,

Rinse



 

postern-length