Other posts related to mac

GIMP on OS X Leopard

jason| February 25, 2008 6:11 pm

I needed to do some image editing over the weekend and installed GIMP on my MacBook Pro, running OS X Leopard, using MacPorts. I was happy to find that some folks have worked hard to integrate GIMP with OS X. Included in the default ‘gimp’ port is a Gimp.app that allows easy launching of GIMP and also facilitates opening GIMP when you double click associated files.

I did have to tweak the Gimp.app package just a tad to get it working with Leopard. The package attempts to start X if it is not already running but doesn’t appear to handle Leopards switch from XFree86 to X.org. Furthermore, this sort launchd provides a launch-on-demand service that launches X11.app if an application tries to open an X $DISPLAY. Below are some quick instructions outlining what I did to get this working.

To install GIMP, install MacPorts, then open up a terminal and type:

sudo port install gimp

Grab a sandwich.

sudo vi \
/Applications/MacPorts/Gimp.app/Contents/Resources/script

Once the install completes, type the following command from the terminal:

This will open the script Leopard no longer requires in the vi editor. Feel free to use your editor of choice, but you will need to run it using sudo to have write permission. I commented out every line except the directory change, just to leave something there, but I’m fairly certain you could do without this entire script. Here’s what mine looks like:

#!/bin/sh
#
# Author: Aaron Voisine <aaron@voisine.org>

CWD="/opt/local"

#ps -wx -ocommand | grep -e '[X]11′ > /dev/null
#if [ "$?" != "0" -a ! -f ~/.xinitrc ]; then
# echo “rm -f ~/.xinitrc” > ~/.xinitrc
# sed ’s/xterm/# xterm/’ /usr/X11R6/lib/X11/xinit/xinitrc >> ~/.xinitrc
#fi

#cp -f "$CWD/bin/getdisplay.sh" /tmp/
#rm -f /tmp/display.$UID
#open-x11 /tmp/getdisplay.sh || \
#open -a XDarwin /tmp/getdisplay.sh || \
#echo ":0" > /tmp/display.$UID

#while [ "$?" == "0" -a ! -f /tmp/display.$UID ]; do
# sleep 1
#done
#export “DISPLAY=`cat /tmp/display.$UID`”

#ps -wx -ocommand | grep -e '[X]11′ > /dev/null || exit 11

cd ~/
exec "$CWD/bin/gimp" "$@"

Once I had GIMP installed, I wanted a quick easy way to change my file associations. The OS X mechanism, in the file info dialog, would require me to find a file of each type I want to open in GIMP to change them. What I found was RCDefaultApp from Rubicode.

RCDefaultApp is a Mac OS X 10.2 or higher preference pane that allows a user to set the default application used for various URL schemes, file extensions, file types, MIME types, and Uniform Type Identifiers (or UTIs; MacOS 10.4 only). MacOS X uses the extension and file type settings to choose the application when opening a file in Finder, while Safari and other applications use the URL and MIME type settings at other times for content not related to a file (such as an unknown URL protocol, or a media stream).

A nice feature of this preference pane is that it allows you to view the extensions a given application is capable of opening and associate them with that application all in one place.

RCDefaultApp Screenshot

So, with the help of MacPorts, a quick hack, and Rubicode, I have all the power of GIMP with all the convenience of an integrated OS X application.