JPEG 2000 on Ubuntu — without anyone getting stabbed

Aargh! Ubuntu 16.10 has decided that ImageMagick doesn’t need JPEG 2000 support, and will quietly (and very very wrongly) write JP2s as JPEG.

(NB: JPEG 2000 images still maybe crash Ubuntu’s file browser in 14.10. My old installation didn’t like them, but my reinstall seems quite happy. Go figure.)

JPEG 2000 is a great image file format: well-defined, and able to store high quality photographic data in a very small space. It truly is the JPEG of the 2000s — except for its dismal support under Ubuntu.

The problem is the patents. An open library has been a long time coming, and lots of Linux software is built without JP2 support. This helped keep it away from my desktop.

Under Ubuntu 14.04, here’s what does and doesn’t support JP2 files:

  • Gimp — not supported. It appears to have a non-functioning plugin that tries to read the file, then gives up. This is annoying, as Gimp is defined as the system default viewer for JPEG 2000.
  • Image Viewer — does support JP2, but occasionally mis-renders pages. To make this the default, right-click on a JP2 file, and select Open with → Other Application …, then choose Image Viewer. It should work from then onwards.
  • Document Viewer — a bit rough when looking at JPEG 2000-encoded PDFs. Very slow, too.
  • GraphicsMagick — seems to be the most painless way of converting graphics files to JPEG 2000. My preferred method of invoking it is:
    gm convert -define 'jp2:rate=0.008' in.png out.jp2
    The rate option should be a small number; the smaller, the greater the compression, and the worse the image quality.
  • OpenJPEG — provides the image_to_j2k and j2k_to_image tools. Far more picky about input formats than it should be, and often fails on seemingly perfect input.
  • img2pdf — (built from source)  is a tiny gem of a package. All it does is wrap various image formats into a PDF file. It doesn’t modify the image data in any way, so with a bit of ingenuity (and pdftk) you can use PDF as a true metafile archive. You can view the content on any platform, but get the source images out bit-for-bit perfect. We used to call files which could contain files metafiles, but that stopped being popular when TIFF started to be a baroque travesty of an image container back in the mid-1990s.
  • poppler — (for full features, build from source) has a tool, pdfimages, which can extract embedded image files from PDFs. Some of the metadata might get lost, but all of the image bits come through.

Since JPEG 2000 isn’t included in web browsers (grar), I’ve embedded a sample scanned JPEG into a PDF, and added a series of progressively more compressed JPEG 2000 versions: JPEG-2000Booklet [PDF].  The booklet has notes showing the byte size of each page. The image still looks pretty good at 8% of the original file size!

optar: paper-based archiving

I’ve spent most of the day messing around with Twibright Optar, a way of creating printed archives of binary data that can be scanned back in and restored.  It looks like it was written as a proof-of-concept, as the only way to change options is to modify the code and recompile. Eppur si muove.

To compile the code on OS X, I found I had to change this line in the Makefile from:

LDFLAGS=-lm

to

LDFLAGS=-lm  `libpng-config --L_opts`

After trying to print some samples at the default resolution, I had no luck, so for reliability I halved the data density settings in the file optar.h:

#define XCROSSES 33 /* Number of crosses horizontally */
#define YCROSSES 43 /* Number of crosses vertically */

It’s quite important that your image prints and scans with a whole number of printer dots to image pixels. This used to be quite easy to do, before the advent of PDF’s “Scale to fit” misfeature, and also printer drivers that do a tonne of work in the background to “improve” the image. Add the mismatch between laser printer resolutions (300, 600, 1200 dpi …) and inkjets (360, 720, 1440 dpi …), and you’ve got lots of ways that this can go wrong.

Thankfully, there’s one common resolution that works across both types of printers. If you output the image at 120 dpi, that’s 5 laser printer dots at 600 dpi, or six inkjet dots at 720 dpi. And there was peace in the kingdom.

Here’s a demo, based on this:

So I took this track (which I used to have as a 7″, got at a jumble sale in the mid-70s) and converted it to a really low quality MPEG-2.5: MichelinJingle8kbit — that’s 175KB for just shy of three minutes of music (which, at this bitrate, sounds like it’s played through a layer of socks at the bottom of the Marianas Trench, but still).

Passing it through optar (which I wish wouldn’t produce PGM files; its output is mono) and bundling the pages into a PDF, I get this: optar_mj.pdf (760KB). Scanning that printout at 600dpi and running the pages through unoptar, I got this: optar1_mj.mp3. It’s the same as the input file, except padded with zeros at the end.

Sometimes, the scanning and conversion doesn’t do so well:

  • mjoptar300dpi.mp3 — this is what happens when you scan at too low a resolution.
  • mjx.mp3 — I have no idea what went wrong here, but: glitchtastic!

Robyn Hitchcock Live at The Mod Club on 2007-11-14

Internet Archive: Details: Robyn Hitchcock Live at The Mod Club on 2007-11-14

Set 1: 81′ 28″

Balloon Man
Autumn Is Your Last Chance
Uncorrected Personality Traits
Olé! Tarantula
Only The Stones Remain
I’m Only You
I Something You
Glass Hotel
Cynthia Mask
No, I Don’t Remember Guildford
Alright, Yeah
Full Moon In My Soul
Swirling
Creeped Out
Queen Of Eyes
Are You Experienced?
You & Oblivion

Set 2: 21′ 24″

Visions of Johanna
(A Man’s Gotta Know His Limitations) Briggs
Adventure Rocket Ship

Casper and The Cookies – Lee’s Palace, Toronto – 20 February 2007

Casper and The Cookies – Lee’s Palace, Toronto – 20 February 2007
It was Jason‘s birthday …

  1. Sid from Central Park
  2. Kiss a Friend
  3. Barking in the Garden of Ill Repute
  4. Neo Dada Hey Day
  5. Sea Fingers
  6. Kroetenwanderung
  7. The Optimist’s Credo
  8. My Heart is in my Head
  9. Learn How to Disappear
  10. Hey Mr. Superstar
  11. Sweet Pea

If you must stream these, here are the playlists: m3u | xspf.

Update: this show is now available on the Internet Archive: Details: Casper and the Cookies Live at Lee’s Palace on 2007-02-20.

Dexit® INSTEAD? No, Dexit is dead

dexit tag

I see that the number of Dexit terminals has reduced to almost nothing, and now they’re offering refunds of outstanding balance. Looks like it’s dead.

I’ve had a love/hate relationship with Dexit. It was almost a great idea, but offered no significant advantage over cash from the bank machine. I wonder how long it will be before you can buy the old terminals in Active Surplus?

very, very old school

Mac OS 7.5.5 Notepad

As I appear to have broken Catherine‘s ability to play Crystal Quest by upgrading her eMac to 10.3.9, I need to find an alternative way to run it. I remember running Basilisk II years ago on a very old Linux box — indeed, my ancient instructions are still here: archive.org :: Installing Mac OS 7.5.3 under Basilisk II on Linux, and quite amazingly, are still useful.

I found the following helpful to get it going under OS X:

outlook contacts to palm, iPod, etc …

This is a neat workaround: Export Outlook Contacts using a small VB script. It works, too — I now have all my work contacts in my Palm.

mame is lame

I suddenly got a retrogaming jones on, and had a strong need to play Robotron. So I downloaded MAME and some ROMs, but no dice — every archive was missing files. Seems that to get the few games I need, I have to download a 16GB torrent of ever game that MAME supports.

My arcade game sensors withered about 18 years ago, so nothing past about 1988 registers with me. You could probably fit every pre-’88 ROM onto a couple of floppies. And it’s not like I’m not allowed to play the ancient Williams games; I have the Arcade Classics CD somewhere which has the games in licensed (but MAME-incompatible) form.

But I’m not singing “At A Time Like This”, I’m singing …

The Hut Sut Song, perhaps the most infectious earworm you’ll ever hear.

… or if you want it a bit more accessible, here is an mp3 of The Hut Sut Song, converted from the same source.

Crappy Lanes: spread the love

Further to Matt Seaton’s article in the Guardian about atrocious cycle facilities, and highlighting Warrington Cycle Campaign’s Facility of the Month, can I just say that Pete Owens of WCC got the idea for the web page from my Crappy Lanes (archive.org copy) site?

mailbox fool

Can you believe the Outlook mailbox limit at work? 60MB. Yup. I’ve been forced to tidy up every week.
I can’y believe a program as widely used as Outlook has so many critical limitations. Storing mail in binary archive files of limited size? Please; so 1989.

I (heart) languagehat

languagehat, on begging the question:

This is one of those issues that is catnip to the adolescent language-lover but which a sensible person grows out of. I too used to enjoy tormenting people with the “truth” about the phrase, but I eventually realized that, whatever its origins … I had never seen or heard the phrase used “correctly” except by people making a point of doing so (cf. “hoi polloi”); in current English usage, “beg the question” means ‘raise the question,’ and that’s that. I got over it …
[T]his … is a sign that the language has sailed on, leaving wistful archaists treading water and clutching at the stern.

Ivor Cutler: Glasgow Dreamer

I’ve archived an MP3 copy of Arnold Brown’s Radio 4 programme here: Ivor Cutler: Glasgow Dreamer. It’s a good introduction to Ivor Cutler’s work, and it’s a bit more accessible than the RealAudio format I had to convert it from.

Nasty Natto from The Sneeze

Steve’s experience with natto — the fermented soy beans of doom — pretty much matches mine, though I suspect he liked it a bit more than I did.

blog entry for dad

My folks have been visiting for the last couple of weeks (we’re just about to leave for the airport), and Dad asked for some links we discussed. The following will probably make little or no sense to other readers:

An apt captcha

apt_captcha.jpg
How apt that, in order to join have_moicy (the Holy Modal Rounders discussion list), I got the above captcha.

Oh, and did I say that we really enjoyed hearing Chris Smither play at Hugh’s Room last Friday?