1

当我想修改 ApplScript 时遇到了一个小问题,我用它来将当前的 iTunes Cover 转换为我通过 GeekTool 在桌面上显示的图像文件。现在我也想调整这个图像的大小,因为有些图像有点小......

我在网上找到了一些解决方案,但没有一个有效……而且由于我对 AppleScript 不太感兴趣,所以我自己也无法处理。

这是我当前的代码:

set the_artwork_file to ((path to home folder) as string) & "Music:iTunes:CurrentArtwork.png"
tell application "System Events"
if ("iTunes" is in name of processes) then
    tell application "iTunes"
        if (player state is not stopped) 
            and (player state is not paused) 
            and (artworks of current track exists) 
            then
            set theArt to front artwork of current track
            set pic to (raw data of theArt)
            try
                set RefNum to (open for access the_artwork_file with write permission)
                write (pic) to RefNum
                close access RefNum
                return
            end try
        end if
    end tell
end if
end tell
do shell script "rm -f " & (POSIX path of the_artwork_file)

好吧,没关系,我终于设法解决了。我生成的代码基本上是正确的,但我不得不把它放到一个单独的脚本文件中。在 GeekTool 中,我必须一个接一个地直接调用它们,它工作得很好!

这是我现在使用的代码:

tell application "Image Events"
    set this_image to open ((path to home folder) as string) & "Music:iTunes:CurrentArtwork.png"
    scale this_image to size 1080
    save this_image in ((path to home folder) as string) & "Music:iTunes:CurrentArtwork.png"
    close this_image
end tell
4

0 回答 0