Forum:PNGOpt expansion: JPEGs and GIFs

From the RuneScape Wiki, the wiki for all things RuneScape
Jump to: navigation, search
Forums: Yew Grove > PNGOpt expansion: JPEGs and GIFs
Archive
This page or section is an archive.
Please do not edit the contents of this page.
This thread was archived on 2 September 2012 by Cook Me Plox.

I have recently discovered some open-source tools that losslessly recompress JPEG files (technically JFIF) and GIF animations: jpegoptim, gifsicle. I want to know if the bot should automatically optimise those image types as well during its monthly optimisation runs and as requested by the new {{compression}} tag. Here are the issues:

JFIF[edit source]

Introduction[edit source]

JFIF, the JPEG File Interchange Format, is a lossy format developed by the Joint Photographic Experts Group. It uses discrete cosine transforms (DCT) controlled by a quality parameter, as well as quantisation, to reduce the details in each 8-by-8 pixel block in an image. The results are then losslessly compressed by Huffman coding. JFIF files may also contain extensions: EXIF data which usually represents camera metadata and creator information, an ICC colour profile and textual comments.

Optimisations[edit source]

It is possible to lossily recompress a JFIF file's image data by re-encoding it at a lower quality setting, which would cause more artifacts. It is also possible to losslessly recompress a JFIF file by optimising the Huffman trees used to compress the 8-by-8 pixel blocks. The lossless recompression is all I'm suggesting.

As far as extensions are concerned, only the ICC colour profile affects rendering; the others take up space needlessly and can be removed.

These optimisations can remove up to 5% in most JFIF images.

On the wiki[edit source]

On the wiki, JFIF files are discouraged for user uploads, but official Jagex images are uploaded verbatim, often as .jpg. Modifying the bytes of these images may contravene the fair use terms under which they are uploaded here. Removing the EXIF data may be the worst offence, but as long as the image is losslessly recompressed, the pixels are effectively unmodified.

At issue is whether to delete comments, whether to delete EXIF data, whether to losslessly recompress the image data, and whether 5% is worth it.

GIF[edit source]

Introduction[edit source]

GIF, the Graphics Interchange Format, was released by CompuServe in 1987, and has two versions: GIF87a and GIF89a. GIF represents 256-colour images with 1-bit transparency using run-length encoding and Lempel-Ziv-Welch compression, as well as uncompressed palettes. GIF can also represent multiple images in one file, which can be turned into animations using the Graphic Control Extension and its delay mechanism. Each image of an animation may have its own Local Palette or use the Global Palette defined in the GIF file's header.

Optimisations[edit source]

A basic technique to reduce the size of animations in GIF files is to represent unchanged pixels in subsequent frames of an animation using transparency, which compresses very well when run-length encoded, and cropping subsequent frames of an animation to the smallest rectangle encompassing non-transparent (i.e. changed) pixels. This changes the animation as stored, but not how it is rendered on the screen.

Another technique to reduce the size of animations is to remove Local Palettes when their colours match those of the Global Palette.

Lossy optimisations exist, which take advantage of the Lempel-Ziv-Welch compression. I'm not proposing to use those here.

These optimisations can remove up to 50% in GIF images, but only if no attempt has been made to remove redundant data. Using gifsicle on the animations shown at Emote, which were already well-optimised, I turned 7,607 KB of files into 6,608 KB, saving 13%. Optimising the Completionist cape animation saved only 81 bytes out of 1,529,574, so the animation must have been optimised before.

On the wiki[edit source]

GIF animations are are not thumbnailed when shown in pages, except when their dimensions are too large (and only the first frame is thumbnailed). Full GIF animations are included in high-profile pages such as Completionist cape, so any savings are an advantage. Modifications are allowed by the license under which GIF animations are uploaded, mostly by users.

At issue is whether to perform this optimisation regardless of the savings, or the percentage of saving required to make a new upload revision.

Discussion[edit source]

Personally I would move for optimising all GIF images, and leaving all JFIF images alone. That would entail deleting the {{compress}} tag on all JFIF images.

 a proofreader ▸ 

22:48, August 15, 2012 (UTC)

Support the above -- per everything said above == Discussion ==. Michagogo (talk) 22:57, August 15, 2012 (UTC)

Support - If you mean compressing like how Malfioz does, go for it. --Recent uploads SpineTalkGuest book 22:58, August 15, 2012 (UTC)

I'm not sure how Malfioz compresses GIF images. Is it with a GUI tool, and if so, which?  a proofreader ▸  23:00, August 15, 2012 (UTC)
I'm not entirely sure. You've going to have to ask him personally. --Recent uploads SpineTalkGuest book 22:06, August 16, 2012 (UTC)
Asking...  a proofreader ▸  22:16, August 16, 2012 (UTC)
Answered. "I use ImageOptim for .gif compression, which unfortunately is only for macs. Hope this helped. Malfioz 15:54, August 17, 2012 (UTC)"
From here: "ImageOptim seamlessly integrates various optimisation tools: PNGOUT, AdvPNG, Pngcrush, extended OptiPNG, JpegOptim, jpegrescan, jpegtran, and Gifsicle." (emphasis mine) So it just encapsulates gifsicle anyway. Yay!  a proofreader ▸  23:02, August 17, 2012 (UTC)

Support - svco4bY.png3Gf5N2F.png 02:38, August 16, 2012 (UTC)

Support - I think it'll be fine, personally. Hair 02:48, August 16, 2012 (UTC)

Oppose - The name will be a lie then. ʞooɔ 03:11, August 16, 2012 (UTC)

Not sure if serious... Hair 03:13, August 16, 2012 (UTC)
ditto^^HaidroH rune.pngEagle feather 3.pngCandle (blood red).png 1XqyDNM.png Crystal triskelion fragment 3.pngHazelmere's signet ring.png 09:21, August 16, 2012 (UTC)
Proposal - I propose that the bot be required to make use of this page. Michagogo (talk) 13:12, August 16, 2012 (UTC)
I see no reason for PNGOptimizationbot to go through some type of name change, just to stop some confusion, because I don't think confusion will occur. Well, if a newer user were to find this bot on a jpg or gif image/animation, they most likely won't understand what optimizing any images/animations means, or what a png image is. Plus, if they do know what it means, I don't see how a bot's username will make them get confused over a file with a .jpg or .gif extension since they know the difference already between files. Also, with a namespace that isn't viewed as much by anonymous users (since they can't upload files/they don't care) or by users with an account (they don't want to upload files/they don't want to do image work/they don't care), only regular image editors/counter vandalism users/maintenance doing users will come across a jpg image/gif animation that was reuploaded by this bot, and will they care or be utterly lost, nope. If someone who is just scrolling through random files in the file namespace comes along a jpg image (which we have few of) or a gif animation (not a lot of them) and wonder why a bot named "PNG"optimizationbot reuploaded this since it doesn't end with .png, they can just deal with it. So, in the end, I see no reason at all for a namechange for a bot hidden in the recent changes. Hair 17:14, August 16, 2012 (UTC)
I already raised this issue in IRC, but it merits a mention here. I will use Special:Contact, as PNGOptimisationBot, to get the account renamed to a name not containing PNG. The exact name will be decided privately when this thread concludes – if at least one additional file type gathers consensus to be compressed – according to availability. I don't wish to put a name here and then be unable to use it because someone saw this thread and hastily registered the name before I could use Special:Contact. That would be a crazy situation!  a proofreader ▸  21:49, August 16, 2012 (UTC)

Support - Why not? — HaidroH rune.pngEagle feather 3.pngCandle (blood red).png 1XqyDNM.png Crystal triskelion fragment 3.pngHazelmere's signet ring.png 09:21, August 16, 2012 (UTC)

Support - Saves fractions of a second off pageload times. 222 talk 10:53, August 16, 2012 (UTC)

Support - Many gif's need compression, yay for Malfioz. User_talk:Fswe1 Fswe1 Brassica Prime symbol.png 11:17, August 16, 2012 (UTC)

Support - dis r kewl ossumsausry. Also it would be useful JOEYTJE50TALKpull my finger 09:45, August 20, 2012 (UTC)

Comment - For the technically inclined, you can see prototype code for the JPEG and GIF optimisation at revision 6121345 of User:PNGOptimisationBot/Source/PNGOptimisationBot.java as well as test out the underlying tools, jpegoptim and gifsicle, on your computer. JPEG and GIF are disabled for the prototype. The configuration directives JPEGMinimumCompressionRatio and GIFMinimumCompressionRatio are added and need to be documented.

 a proofreader ▸ 

00:28, August 21, 2012 (UTC)

Closed - There is consensus to let A_proofreader do whatever she wants. ʞooɔ 22:26, September 2, 2012 (UTC)