Display iTunes artwork in Growl notifications

Mar 14, '14 07:00:00AM

Contributed by: philostein

OS X and Growl notifications are AppleScriptable and great for displaying user-defined text, but not so hot for user-defined images. OS X can only display the sending application's icon, and Growl no longer accepts raw iTunes artwork image data or regular image files.

Growl's iTunes limitation can be overcome by converting an iTunes track's raw artwork image data into a TIFF file that can be read and passed to Growl:

tell application "iTunes" to set _rawData to raw data of artwork 1 of current track

set _startupDisk to (path to startup disk as text)

set _tempTiffFile to (open for access file (_startupDisk & "tmp:iTunesTiffArtwork.tiff") with write permission)
try
	write _rawData to _tempTiffFile starting at 0
	close access _tempTiffFile
on error a number b
	close access _tempTiffFile
end try

-- Use 'sips' to make it a TIFF file:
do shell script "sips --setProperty format tiff /tmp/iTunesTiffArtwork.tiff"

set _tempTiffFile to open for access file (_startupDisk & "tmp:iTunesTiffArtwork.tiff")
try
	set _readImage to read _tempTiffFile as "TIFF"
	close access _tempTiffFile
on error a number b
	close access _tempTiffFile
end try

tell application id "com.Growl.GrowlHelperApp"
	set the allNotificationsList to {"AppleScript Notification", "Another AppleScript Notification"}
	set the enabledNotificationsList to {"AppleScript Notification"}
	register as application "Growl AppleScript Sample" all notifications allNotificationsList ¬
		default notifications enabledNotificationsList icon of application "iTunes"
	
	notify with name "AppleScript Notification" title ¬
		"Current Track's Artwork" description "Converted to a TIFF file in '/tmp'" ¬
		application name "Growl AppleScript Sample" image _readImage with sticky
	
end tell
The above script should display the current track's artwork in a Growl notification. Here's a script that displays iTunes artwork and a lot of other useful track information. It looks like this.

[crarko adds: I haven't tested this one. I did verify that the scripts compile, and that the downloadable script is safe. At the moment, I don't have the ability to archive that script here for FTP, but I'm working on that.]

Comments (0)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20140301160720721