miriam_e: from my drawing MoonGirl (Default)
[personal profile] miriam_e
Last night, after watching Robert Murray-Smith's wonderful short video about the Accutron mechanism, in which he mentions an amazing book, "1800 Mechanical Movements Devices and Appliances" by Gardner D Hiscox published in 1921, I went ahead and downloaded it:
https://archive.org/details/1800-mechanical-movements-devices-and-appliances_202005

Depending on the kind of book I'm fetching I'll get one format or another. The InternetArchive almost always has a link to "SINGLE PAGE PROCESSED JP2 ZIP". I generally don't use that link, even though it is a zip file of the original page image scans in extremely high quality JPEG2000 format, because I have almost nothing to view the images or convert and resize them to something smaller and more usable. ImageMagick needs a special "delegate" converter which I haven't been able to get working. Netpbmtools' converter fails to even read the images. G'MIC needs a special computer vision library which I'm reluctant to add to my computer. And none of the dedicated viewer programs I have will even display it.

Just two programs will load jpeg2000 images: Gimp, and mtpaint.

I'd kinda expected Gimp would be able to. It is big and extremely capable -- able to do much, much more than I could learn in one lifetime.

The great surprise was mtpaint -- a tiny, exceedingly fast, deceptively simple, paint program. And I dimly recalled from somewhere that mtpaint could be used from the commandline without opening the GUI (graphical user interface). So I typed into the terminal:
mtpaint --help

It responded with:
mtPaint 3.49.13

Usage: mtpaint [option] [imagefile ... ]

Options:
  --help          Output this help
  --version       Output version information
  --cmd           Commandline scripting mode, no GUI
  -s              Grab screenshot
  -v              Start in viewer mode
  --              End of options

There it was, commandline scripting mode! I'd been greatly underestimating little mtpaint.

Next, I quickly looked through its manual to see what I could learn about its scripting mode, but didn't look closely enough so I missed it.

It occurred to me to ask ChatGPT-4o. It seemed very helpful, giving lengthy descriptions of how to use mtpaint scripting. So then I sat down to try its examples... but none of them worked.

So now I examined the manual more closely and found chapter 10 discussed scripting. It turns out EVERY example GPT gave was wrong, and not just in minor ways, but in every way. That really surprised me.

The only thing left was to patiently read through the manual's chapter on the topic.

I'm quite pleased at its scripting language. It uses the GUI as its reference. Commands are based upon it. So if I want to know the way a command should be written I simply find it in the program's GUI and that will define it for me. Very smart. For example if I want to load a jp2 image, scale it to 22%, with proportions fixed so height and width scale together, then save as an ordinary jpg image at 90% quality, then I write this on the commandline:
mtpaint --cmd -file/open="00.jp2" -image/scale w=22% fix=1 -file/as="00_22.jpg" f=jpeg q=90

The "file" menu in the GUI contains the "open" and "save as" commands, and the "image" menu contains the "scale" command. The other settings are part of those commands in the GUI, so immediately follow those commands with an unambiguous key (for example "width" or "w" both work fine).

Using mtpaint on the commandline I can quickly and easily convert and rescale hundreds of jp2 images to usable size and format using a simple looping command. Yay!

One last thing. I mentioned that I didn't have a program that would simply display jpeg2000 images. I was wrong. I noticed mtpaint has another little surprise. If I make the mimetype command for all jp2 images
mtpaint -v "$@"
then mtpaint displays them in its own fast, simple picture viewer.

I have great new respect for mtpaint. I'd been underestimating it awfully.
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

miriam_e: from my drawing MoonGirl (Default)
miriam_e

May 2025

S M T W T F S
    123
45678910
11121314151617
18192021222324
252627282930 31

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 15th, 2025 12:53 pm
Powered by Dreamwidth Studios