iTunes and Artwork Success errors

I am unable to find any information on the error that this snippet is creating.

set theImage to read (choose file) as picture
tell application "iTunes"
	set theP to view of front window
	tell theP
		try
			set data of artwork 1 of track 1 to theImage
		on error errMsg number errNum from errFrom partial result errResult to errTo
			display dialog errMsg
		end try
	end tell
end tell

iTunes got an error: An error of type -116 has occurred.

I have also tried this:

set theData to "Macintosh HD2:Users:brandonc:Desktop:0008539373162_500X500.jpg" as alias
set theImage to read (theData) as picture
tell application "iTunes"
	set this_track to (item 1 of index of selection)
	set theP to view of front window
	tell theP
		set theArt to front artwork of track this_track
		--set pic to (data of theArt) as picture
		try
			set data of theArt of this_track to theImage as picture
		on error errMsg number errNum from errFrom partial result errResult to errTo
			display dialog errMsg
		end try
	end tell
end tell

errFrom = theArt of 1
errMSG = Can’t get theArt of 1.
errNum = -1728
errResult = list of 0 items
errTo = list of 0 items

This gives me a differant error, probably due to not having built a list.
I could use some insight to how to do this bit of code.

There has been a lot of discussion of this here and elsewhere (search for iTunes & artwork on this board or iTunes & artwork & applescript on Google). I’ve found that the code only works when using PICTs as the source and then, you need to strip off the first 512 bytes (the file header). With those caveats, this should work:

For more information and script ideas, you can also take a look at my page which has more source code.

Jon

Thanks for the tips and the links. I will use it.