Problem displaying iTunes artwork in Growl notification

This script worked fine in Snow leopard but it stopped to work with Lion.

-- https://gist.github.com/275067/3acc381e6c830e059607f84aa9db31f4ed222290
-- by mfilej
--
-- changed to show rating 
-- better display for streams . espescially radio streaming  
-- by Ptujec

-- Display the track if iTunes is running
on run
	if appIsRunning("iTunes") then
		tell application "iTunes"
			if exists name of current track then
				set aTrack to the current track
				set aDescription to the name of aTrack
				
				-- Podcast
				if aTrack is podcast then
					set aTitle to the name of aTrack
					set aDescription to the description of aTrack
					
					
				else if artist of aTrack is not "" then
					set aTitle to the artist of aTrack
					
					
					-- Stream
				else if artist of aTrack is "" then
					set aTitle to aDescription
					if current stream URL contains "http" then
						set aDescription to current stream title
					end if
					
				end if
				
				-- rating 
				if rating of aTrack is 100 then
					set rating_ to " ★★★★★"
					-- else if rating of aTrack is 80 then
					--	set rating_ to " ★★★★"
					-- else if rating of aTrack is 60 then
					--	set rating_ to " ★★★"
					-- else if rating of aTrack is 40 then
					--	set rating_ to " ★★"
					-- else if rating of aTrack is 20 then
					--	set rating_ to " ★"
				else
					set rating_ to " "
				end if
				
				-- User artwork as icon if available otherwise default icon (iTunes icon)
				if (count of artwork of aTrack) ≥ 1 then
					delay 1
					set anArtwork to data of artwork 1 of aTrack
					
					my growlRegister()
					tell application "GrowlHelperApp" to notify with name "Song Info" title aTitle description aDescription & rating_ application name "iTunes - Song Info" priority 0 pictImage anArtwork
				else
					my growlRegister()
					tell application "GrowlHelperApp" to notify with name "Song Info" title aTitle description aDescription & rating_ application name "iTunes - Song Info" priority 0
				end if
			else
				my growlRegister()
				tell application "GrowlHelperApp" to notify with name "Error" title "Error" description "No song playing" application name "iTunes - Song Info" priority 2
			end if
		end tell
	else
		my growlRegister()
		tell application "GrowlHelperApp" to notify with name "Error" title "Error" description "iTunes not running" application name "iTunes - Song Info" priority 2
	end if
end run

-- Check if application is running
on appIsRunning(appName)
	tell application "System Events" to (name of processes) contains appName
end appIsRunning

-- Register with Growl
on growlRegister()
	tell application "GrowlHelperApp"
		register as application "iTunes - Song Info" all notifications {"Song Info", "Error"} default notifications {"Song Info", "Error"} icon of application "iTunes"
	end tell
end growlRegister

I was able to get rid of the error message by changing

if (count of artwork of aTrack) ≥ 1 then

to

if exists artwork of aTrack then

. but this still doesn’t give me the artwork image in the Growl notification.

Does anyone have a fix for that?

I believe it has todo with a change that the image data is now jpg and not pict anymore.
Growl can’t handle this. Anyone now how to put the raw data into an image in a temporary directory. Cause Growl can handle that.

Would really appreciate a hint.

I’m not an expert on this subject, but I suspect ImageMagick can help you. If you can figure out how it works, the solution is probably just a few shell scripts away.

Also, Growl was just updated to 1.3 and released in the Mac App Store. I haven’t checked to see if there are any changes to scripting API yet.

Ok. I found it in here . http://dougscripts.com/itunes/scripts/ss.php?sp=savealbumartjpeg
And here is the updated script. (For more see: https://github.com/Ptujec/iTunes/)

-- https://gist.github.com/275067/3acc381e6c830e059607f84aa9db31f4ed222290
-- by mfilej
--
-- changed to show rating 
-- better display for streams . espescially radio streaming  
-- by Ptujec
--
-- 2011-10-05
-- changed to convert image data to a tempory jpg file (due to changes of iTunes artwork image data)
-- with help of http://dougscripts.com/itunes/scripts/ss.php?sp=savealbumartjpeg

-- Display the track if iTunes is running
on run
	if appIsRunning("iTunes") then
		tell application "iTunes"
			if exists name of current track then
				set aTrack to the current track
				set aDescription to the name of aTrack
				
				-- Podcast
				if aTrack is podcast then
					set aTitle to the name of aTrack
					set aDescription to the description of aTrack
					
					
				else if artist of aTrack is not "" then
					set aTitle to the artist of aTrack
					
					
					-- Stream
				else if artist of aTrack is "" then
					set aTitle to aDescription
					if current stream URL contains "http" then
						set aDescription to current stream title
					end if
					
				end if
				
				-- rating 
				if rating of aTrack is 100 then
					set rating_ to " ★★★★★"
					-- else if rating of aTrack is 80 then
					--	set rating_ to " ★★★★"
					-- else if rating of aTrack is 60 then
					--	set rating_ to " ★★★"
					-- else if rating of aTrack is 40 then
					--	set rating_ to " ★★"
					-- else if rating of aTrack is 20 then
					--	set rating_ to " ★"
				else
					set rating_ to " "
				end if
				
				-- User artwork as icon if available otherwise default icon (iTunes icon)
				if (count of artwork of aTrack) ≥ 1 then
					set _artist to the artist of aTrack
					set _name to the name of aTrack
					
					set _home to POSIX path of (path to home folder)
					set pathToNewFile to (_home & "TMP/" & _artist & "_" & _name & ".jpg") as string
					tell me to set file_reference to (open for access pathToNewFile with write permission)
					tell application id "com.apple.iTunes" to write (get raw data of artwork 1 of aTrack) to file_reference starting at 0
					tell me to close access file_reference
					-- delay 0.5
					
					my growlRegister()
					tell application "Growl" to notify with name "Song Info" title aTitle description aDescription & rating_ application name "iTunes - Song Info" priority 0 image from location pathToNewFile
				else
					my growlRegister()
					tell application "Growl" to notify with name "Song Info" title aTitle description aDescription & rating_ application name "iTunes - Song Info" priority 0
				end if
			else
				my growlRegister()
				tell application "Growl" to notify with name "Error" title "Error" description "No song playing" application name "iTunes - Song Info" priority 2
			end if
		end tell
	else
		my growlRegister()
		tell application "Growl" to notify with name "Error" title "Error" description "iTunes not running" application name "iTunes - Song Info" priority 2
	end if
end run

-- Check if application is running
on appIsRunning(appName)
	tell application "System Events" to (name of processes) contains appName
end appIsRunning

-- Register with Growl
on growlRegister()
	tell application "Growl"
		register as application "iTunes - Song Info" all notifications {"Song Info", "Error"} default notifications {"Song Info", "Error"} icon of application "iTunes"
	end tell
end growlRegister