Module: image_optimizer - lossless optimization of thumb/resize images and lossless rotation of full-size images

shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Tue, 2012-12-04 14:45

Image Optimizer uses three underlying toolkits, all performing lossless transformations on GIF, JPG, and PNG images. These are used to alter:
* Resize and thumb image optimization: reduce the size/nature of thumb and resize images so they load faster
* Full-size image rotation: ensure that rotations of JPG images are made losslessly (this is not the case with ImageMagick, etc.)

The three toolkits used by the module are:
* Jpegtran by Jpegclub
* OptiPNG by Cosmin Truta et al.
* GIFsicle by LCDF

The module comes with all three toolkits pre-compiled as libraries. By default it uses them, but can be configured to use copies installed elsewhere on your server instead.

The module's lib directory includes both Windows and Linux versions of the toolkits. For security reasons, Windows should not be used on production sites. Both versions are provided here to enable development copies to still run Windows without issue.

This module was inspired by the WordPress module EWWW Image Optimizer and the Gallery3 module Jpegtran.

== Features ==
The module is fully-configurable, and can be set to perform any combination of the following:

Full-size image manipulation
* use Jpegtran for lossless rotations
Thumb and resize image manipulation
* Compression optimization (lossless). Recommended for thumbs and resize images.
* Remove all meta data. Recommended for thumb images - 80% size reduction typical, which drastically changes page load speed.
* Make images progressive/interlaced (lossless). Recommended for resize images - provides preview of photo during download.
* Image format conversion (not necessarily lossless). Recommended for thumb images - converting PNG/GIF to JPG can reduce the size by a huge amount, helping page load speed.

Documentation is available at the normal location at http://codex.gallery2.org/Gallery3:Modules:image_optimizer

Downloads are available as attached here:
* image_optimizer_1.zip - complete module with included pre-compiled libraries for Linux
* image_optimizer_1_win.zip - supplement to add to module to include pre-compiled libraries for Windows also. For security reasons, Windows should not be used on production sites. Both versions are provided here to enable development copies to still run Windows without issue.

Let me know what you think!

Take care,
Shad

AttachmentSize
image_optimizer_1.zip1004.09 KB
image_optimizer_1_win.zip259.67 KB
 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2012-12-05 02:49

Thanks for the contribution!
And the codex page as well

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
jnash
jnash's picture

Joined: 2004-08-02
Posts: 814
Posted: Wed, 2012-12-05 14:19

I have yet to test this out as I've been tied up with other things lately. Does the module go back through existing images and optimize as well? (a maintenance task or something?)

I'll give it a shot this weekend.

Thanks!

James

 
shadlaws

Joined: 2012-03-14
Posts: 183
Posted: Wed, 2012-12-05 15:06

@Dave - thanks much!

@James - yes it can, and it even has a clever mode you can use to make it happen faster. Here's the blurb from the codex doc page:

By default, the module only affects new images. There are two additional features in the admin settings to help rebuild of all your existing thumb and resize images.
* Mark all existing images for rebuild (for thumbs and resizes separately). Afterward, go to Maintenace -> Rebuild Images. Depending on your gallery size, this can be very time consuming.
* Enable update mode. This deactivates all other graphics rules to allow fast optimization on existing images; MUST deactivate this after initial rebuild! No new images should be added to the gallery while this is enabled! This will add site message banners to remind you of its presence.

Thanks!

Take care,
Shad

 
jnash
jnash's picture

Joined: 2004-08-02
Posts: 814
Posted: Wed, 2012-12-05 15:16

Ahhh, always helpful to read the docs eh? Thanks so much! Awesome contribution.

 
RalphTheWonderLlama

Joined: 2005-07-16
Posts: 68
Posted: Thu, 2013-08-01 20:10

Wow this is awesome! Thanks shadlaw, I will definitely have to try it! I noticed on Google PageSpeed that most of the images on my homepage could be reduced in size by over 50% and up to 84%!!! I had seen that before when using PageSpeed but I didn't realize it had said "lossless" until now and when I saw that I had to do some investigation. I didn't realize there was such possible lossless JPEG and PNG compression. I thought I already picked my compression level and that was that.

I basically use Gallery, in addition to being a gallery, as a way to host images on my main Wordpress site in blog posts and such (often rather than the the media upload in Wordpress) so this could have a big impact for me, especially on pages with lots of images used this way. It's awesome to learn about this and then come here and find a plugin.

Since this is compressing the resize and thumbs and not the original, maybe this should be just "the way it works" out of the box and this method integrated with main Gallery. Why not? I know G devs guard against adding things for G3 that don't fit in the core that everybody would use but this one seems like an easy one to me.

 
RalphTheWonderLlama

Joined: 2005-07-16
Posts: 68
Posted: Wed, 2013-08-14 00:06

Well, two tries of it and it doesn't seem to have changed my thumbnails. I saved a folder of my album thumbnails before, and then tried running this, once with the "update mode" enabled, and once without, and the new thumbnails are the same size. Big thing is though that I am having problems doing the rebuild. The run without "update mode" enabled took me almost a week of checking and clicking for my 1700 photos because it stalls after doing so many (often about 20 at a time). So I certainly have some other problems. I'm using Bluehost and Gallery 3.0.4. The first run I was just clicking the link in the yellow notification at the top "click here to fix them", but in the second run I used the Maintenance screen. It says it's finished and I don't see any errors. Any ideas for me to try?

 
olygoelements

Joined: 2013-12-13
Posts: 2
Posted: Fri, 2013-12-13 15:12

OptiPNG
GIFsicle

are no more downloadable. the link are dead :(

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2013-12-13 23:19

fixed the links and updated the codex page.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
olygoelements

Joined: 2013-12-13
Posts: 2
Posted: Sat, 2013-12-14 09:49

thanks

 
slart

Joined: 2013-11-11
Posts: 112
Posted: Wed, 2014-03-12 15:45

Hello, i have more questions to the module.
first. in the admin page i read this:
"JPG Jpegtran by Jpegclub /usr/bin/jpegtran Correctly configured! sh: /var/www/virtual/xxx/html/xxxx/modules/image_optimizer/lib/jpegtran: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory"
"PNG OptiPNG by Cosmin Truta et al. /usr/bin/optipng Correctly configured! OptiPNG version 0.7.4"
"GIF GIFsicle by LCDF (not found) Correctly configured! LCDF Gifsicle 1.67"
is it OK or not?

edit:
Sorry, I sometimes have problems with understanding of technical English. And sometimes smokes my skull, and I overlooked the easiest. ;)

I must put the path from "Server-installed path" to Toolkit paths, and all works fine. almost...

 
slart

Joined: 2013-11-11
Posts: 112
Posted: Wed, 2014-03-12 17:15

Hello, I have answered my questions confused by the previous post itself.
But I have a new question.
Currently I have all thumbs and Resizes rebuild. That took a lot of time. Now it is stuck and I broke it. The message in the admin section Maintenace is now: "Rebuild Images You have 2 out of date photos"
I have started it again, but it rebuild "0" images of 2
Did I 2 orphaned photos in the database registered?
I have all the albums (pages) is searched and no broken (thumb) images found.
Is there a log file?

I have seen also that the settings are in the Resizes this:
JPEG, progressive, quality: 100, subsampling OFF.
100% is a bit much, right? subsampling OFF is good? Better 4:2:0 (2x2)? Can I change this and if so where? Untouch In the Gallery3 is default 75% for Resizes.
Is it also possible to take the JPG quality% from the original?

 
slart

Joined: 2013-11-11
Posts: 112
Posted: Wed, 2014-03-12 20:27

I have just uploaded a new album with "upload from server".
And then I noticed that I had are in the settings -> advanced -> gallery image_quality 100. Now I have changed it to 75. Then again rebuild all images. and now it's all fine. except for the 2 out of date photos.

I have no idea why the subsampling was OFF. My originals have this setting:
JPEG, progressive, quality: .., subsampling ON (2x2)
Original quality is different.

In the default settings of Gallery the thumbs and .album.jpg in 100% jpg quality. Is that right?
Now with this module as well as the Resizes (75%) after rebuild.
I am a bit overwhelmed. ;)

Thanks shadlaws, it's a big fine module!
The good one is, rebuild include the .album.jpg.