set pathToImage to ":path:to:image"
tell application "iTunes"
set currentArtwork to (read file pathToImage from 513 as artwork)
set artwork 2 of current track to currentArtwork
I get a ‘parameter error’. If there is already artwork in position 2, it works fine. Therefore, I think that the solution must have something to do with creating new artwork and inserting it into the iTunes track. However, I have not yet figured out how to do this.
Does anyone have any thoughts or comments on how to accomplish this?
My script was tested on Mac OS X 10.3.9 and iTunes 4.7.1 (30). iTunes had some trouble with “current track” unless the current track was actually playing. Not sure why that is. Anyway, the code I posted above worked for adding new artwork to a track regardless of what was already there (0, 1, or more artworks). Are you using a PICT file or some other file as the artwork? This only worked for me when using PICTs (and, indeed, the code you reference for reading from byte 513 on is meant to strip the header from PICT files, not other types of image files).