OS X: Getting Image-Dimensions on the Command-Line (sips)

If you need to get the dimensions of an image-file via the command-line, let’s say in a script or an AppleScript, then there is a way to do so easily. Enter the scriptable image processing system or short sips. You didn’t know you got that installed on your OS X system alreay? Me neither.

Assume, that we need to get the dimensions of an image for further handling of said image. The command

sips -g pixelWidth -g pixelHeight [image-file]

returns the values (and a lot more if asked correctly).

Give it a try and take a look at the man-page (man sips) for further information. A really handy tool for all scripters.

MySQL-Endcoding on OS X Server 10.5.X

Just a quick hint for all the commandline-jockeys: The standard-encoding for new MySQL-Databases on OS X Server 10.5.X is not UTF-8 but latin1.

Do not forget to specify the encoding when creating a new database, seriously. I suspect, that this depends on the language the system is installed in. The system that tricked me was using english, naturally. πŸ˜‰ It didn’t help much, that WordPress thought writing to a databases using UTF-8 encoding. Everything worked fine until I dumped the database and restored it on another system.

Alternatively, there is no my.cnf in the standard-locations on a clean OS X Server 10.5.X install, create one and specify the right encoding there. But get in the habit of checking the current default encoding before creating a new database.

Just a quick FYI. πŸ˜‰

My DocBook-Bundle for TextMate

OK, here it is. The TextMate DocBook-bundle (click the link to download) I’m using for production.

The emphasis is on I’m using. The bundle contains the entities I need for my daily work. Means, it does not contain all entities which can be used writing books and articles in DocBook. There are no templates, since I’m tweaking my DocBook-workflow at the moment.

You can use the bundle to ease the pain regarding spurious >-signs by writing e.g. application or systemitemnext to the </para>-tag and hit the ⇥-key, instead of typing <-⇥ and removing the additional > appearing next to the </para>-tag. There are indexterms, xrefs, ulinks, etc. Check it in the Bundle-Editor in TextMate.

On shortcut probably needs explanation, if you type entity followed by ⇥, a line appears copying the symbolic name used in the document, e.g. ch08 to the end of the same line with the extension .xml added. I tend to (especially late at night) introduce typos in the filenames. :mrgreen: The result is a run-of-the-mill entity-declaration like this:

<!ENTITY ch08 SYSTEM "ch08.xml">

It’s your job to include the entity at the right spot in your master-document.

There is no sanity-check whatsoever, you have to make sure, that the structure is OK. The bundle is not a tool to teach anyone, it’s a tool to speed up my writing. If you are not sure about the “parents” or “children” allowed for a tag, take a look at DocBook: The Definitive Guide.

Templates will be included in one of the next incarnations. I’m thinking about adding the creation of PDFs using fop to the bundle, for the time being, you’ll have to use your own scripts. Watch this space.

I hope you can put the bundle to use. If there is anything you miss, drop me a comment (moderated).

If you have no idea what TextMate is and you are using a Macintosh running OS X to write in DocBook, check out the link, seriously.

10.5.2, at last

Everybody fantasized, hoped, longed, [you get the picture] about it: the Leopard 10.5.2 Update is soon to be found on Macs wide and far.

No problems so far, none I’m aware of, at least. Don’t forget to repair the permissions before and after the install, though. Seriously. And if you happen to have a recent digital camera in your bag, one of those to be precise:

  • Canon EOS 1Ds Mark III
  • Canon Powershot G9
  • Hasselblad CF-22
  • Hasselblad CF-39
  • Leaf Aptus 75s
  • Nikon D3
  • Nikon D300
  • Sony Alpha DSLR-A700

Then messing up the pictures in RAW is at your disposal. :mrgreen:

Just in case you managed to miss the news. πŸ˜‰

TCP- and UDP-Ports used by Apple Software

Everyone concerned with administering a network containing Apple-machines should bookmark this link:

“Well Known” TCP and UDP ports used by Apple software products

I’ve been told, that the document will be updated on a regular basis.

Date-/Time-Calculations using AppleScript

This short how-to explains how you calculate with time- and date-values in AppleScript. Quite a few people told me, that they are using the do shell script-handler presented in the post How to convert an β€œepoch”-time to a meaningful date and time. Nothing wrong with that, but if you just want to perform time-calculations inside an AppleScript, then there is an easier way.

If you assign the current time to a variable as in set myDate to current date and you just want to calculate the current date plus 2 days, then there is no need to use epoch-seconds.

  1. set myNewDate to myDate + (2 * days), adds 2 days to the date and time stored in myDate.
  2. set myNewDate to myDate + (4 * hours), adds 4 hours to the current time and date.
  3. set myNewDate to myDate + (30 * minutes), adds 30 minutes to the current time and date.

It is really that simple, AppleScript uses epoch-seconds to perform these calculations, so you don’t have to. πŸ˜‰

If you need to set the date and time to the beginning of the current day, then use

set myTime to time of myDate

set myNewDate to myDate - myTime

The variable myNewDate now contains the current date and 00:00:00 as time.

Epoch-seconds are great if you want to store a date-value and read it back in later, but as long as you stay inside an AppleScript, there is no need to resort to epoch-values.

Happy Thanksgiving everyone!

If you are reading this on thursday: Before or after turkey (I’m nosy)? πŸ˜‰

OS X: Restoring Addressbook-Entries with Time Machine

Everyone agrees, that Time Machine makes your life a lot easier. Did you know about the fact, that programmers are able to integrate it into their applications?

For example, open iCal and click on Time Machine in the Dock. Now you are able to move back in time and restore deleted or changed entries. Sneaky. πŸ˜‰

But the fun does not stop here, you are able to restore mailboxes as well. The mechanism does not work with RSS-Feeds in Mail, though.

Leopard 10.5.1 Update

It’s update-day today. First 10.4.11 now 10.5.1.

No problems with 10.4.11 so far.

I installed the 10.5.1 update via software update first and got a couple of messages while repairing permissions afterwards. A bunch of SUID program … not repaired to be precise. I decided to download the combined patch from Apple’s download section and applied it as well. The messages are gone, except the one about ARD which appeared after the initial install of Leopard. This seems to be a known problem according to this message, though.

Tiger Update 10.4.11

Apple released the 10.4.11 Update, it includes the Security Update 2007-008. Based on the information in the links, get it ASAP, seriously.

As a bonus, Apple added support for some more cameras:

Adds RAW image decoding support for the following cameras: Panasonic Lumix DMC-FZ50, Leica V-Lux 1, Olympus E-400, Olympus EVOLT E410, Olympus EVOLT E510, Canon EOS 40D