[GTALUG] Help need in bash

Stewart C. Russell scruss at gmail.com
Fri Jun 1 13:26:10 EDT 2018


On 2018-06-01 10:34 AM, D. Hugh Redelmeier via talk wrote:
> 
> | Using convert is okay, but you won't end up with the smallest JPEGs that
> | way.
> 
> What do you recommend?  (Lightning talk?)

oh I wish - the next couple of weeks I'm running more events than is
sensible.

anyway, of course I've overthunk this, so some notes in lieu:

* cjpeg - the IJG/libjpeg-turbo command offers easier access to JPEG
options than IM/GM's convert, such as greyscale

* you can very often have a much lower JPEG quality than defaults, but
keep the originals somewhere safe 'cos JPEG is lossy

* don't use arithmetic-coding compressed JPEGs: the browser support is nil

* (almost all) JPEGs are made up of 8×8 px colour approximation cells.
If your image isn't an exact multiple of 8 px in each direction, you're
going to waste space in the file

* consequently, cropping a JPEG can do unexpected bad things to the
output. jpegtran — another IJG/libjpeg-turbo tool — is one of the very
few programs that can do a true lossless crop of a JPEG file

* JPEGs are for continuous-colour photographic images, and any sharp
change in colour — like you'd get in computer-generated or line graphics
— causes weird colour fringes / artifacts around the edges. The "modern"
way to deal with this is to rack the JPEG quality up to 95%+ and live
with huge files. The "right" way to deal with this is to add a *tiny*
bit of colour noise to the image, and it will kill the fringes off.
(JPEGs essentially store the result of signal processing the source
image rather than the image itself. If you've ever played with signals
(analogue or digital), sharp edges in any input waveform can cause
"filter ringing" or unwanted harmonics in the output. JPEG fringes are
unwanted filter harmonics, basically)

* BUT … nobody really cares (or needs to) about JPEG size these days as
every webpage is megabytes of crap anyway.

* almost nobody (outside specialist domains) uses the replacement for
the JPEG format, JPEG-2000. This is a shame, as it has some very nifty
features like progressive viewing (so an overview will only load a small
part of the file) and truly impressively tiny file sizes. JPEG-2000
takes a fair amount of processing power to render (deemed too much/too
slow for the web circa 2001) and was until recently encumbered by some
annoying patents. Ubuntu deals with this very badly by patching a bunch
of tools (like ImageMagick) such that when you ask for JPEG-2000, it
gives you a JPEG. This is bad and wrong and they must get off my lawn
forthwith.

cheers,
 Stewart

(Oh, and if you've made it this far: I see that local(ish) Linux-friend
Bob Jonkman is standing as a Green candidate in Kitchener-Conestoga:
https://gpo.ca/candidate/bob-jonkman/)


More information about the talk mailing list