Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从Applescript中的当前曲目获取艺术品_Applescript_Itunes_Artwork - Fatal编程技术网

从Applescript中的当前曲目获取艺术品

从Applescript中的当前曲目获取艺术品,applescript,itunes,artwork,Applescript,Itunes,Artwork,我正试图制作一个脚本,将当前播放曲目的艺术作品拉出来,并将其写入一个文件。我查阅了一些指南,但没有一本有效,有什么建议吗 tell application "iTunes" write artwork 1 to "path:to:desktop" of type("JPEG") end tell 老实说,我不知道我在做什么。有人觉得有帮助吗 谢谢您可以将当前曲目的艺术品1的原始数据写入文件: -- get the raw bytes of the artwork into a var tell

我正试图制作一个脚本,将当前播放曲目的艺术作品拉出来,并将其写入一个文件。我查阅了一些指南,但没有一本有效,有什么建议吗

tell application "iTunes"
write artwork 1 to "path:to:desktop" of type("JPEG")
end tell
老实说,我不知道我在做什么。有人觉得有帮助吗


谢谢

您可以将当前曲目的
艺术品1的原始数据
写入文件:

-- get the raw bytes of the artwork into a var
tell application "iTunes" to tell artwork 1 of current track
    set srcBytes to raw data
    -- figure out the proper file extension
    if format is «class PNG » then
        set ext to ".png"
    else
        set ext to ".jpg"
    end if
end tell

-- get the filename to ~/Desktop/cover.ext
set fileName to (((path to desktop) as text) & "cover" & ext)
-- write to file
set outFile to open for access file fileName with write permission
-- truncate the file
set eof outFile to 0
-- write the image bytes to the file
write srcBytes to outFile
close access outFile

您也可以使用,但它不包括源代码。

太棒了,谢谢。我不知道你可以发送一个'告诉'在应用程序内的对象艺术品。