如何使用 obj-c AppScript 将图稿添加到 iTunes 曲目?

发布于 2024-08-25 06:05:28 字数 800 浏览 8 评论 0原文

aTrack 是一个 ITReference* 对象,值是一个 NSImage* 对象,通过 jpeg 的 URL 初始化。

[[[[[aTrack artworks] data_] set] to:value] send];

我在 GDB 中收到以下消息:

2010-03-09 16:59:42.860 Sandbox[2260:a0f] Can't pack object of class NSImage (unsupported type): <NSImage 0x10054a440 Size={0, 0} Reps=(

然后我尝试了以下代码:

NSData *imageData = [[NSData alloc] initWithData:[value TIFFRepresentation]];
[[[[[aTrack artworks] data_] set] to:imageData] send];

并收到此消息

2010-03-09 16:46:09.341 Sandbox[2193:a0f] Can't pack object of class NSConcreteData (unsupported type): <4d4d002a 00000000>

在 AppScript 文档中,它说“artwork”项的“data”属性是 PICTPicture 图像。

如何将 NSImage 转换为 PICT?我使用 AppScript 是否完全错误?

aTrack is an ITReference* object, value is an NSImage* object, initialized via a URL to a jpeg.

[[[[[aTrack artworks] data_] set] to:value] send];

I get the following message in GDB:

2010-03-09 16:59:42.860 Sandbox[2260:a0f] Can't pack object of class NSImage (unsupported type): <NSImage 0x10054a440 Size={0, 0} Reps=(

I then tried the following code:

NSData *imageData = [[NSData alloc] initWithData:[value TIFFRepresentation]];
[[[[[aTrack artworks] data_] set] to:imageData] send];

and get this message instead

2010-03-09 16:46:09.341 Sandbox[2193:a0f] Can't pack object of class NSConcreteData (unsupported type): <4d4d002a 00000000>

In the AppScript documentation, it says that the "data" property of the "artwork" item is a PICTPicture image.

How do I convert an NSImage to a PICT? Am I using the AppScript all wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清风挽心 2024-09-01 06:05:28

Appscript 不会桥接 NSImage,部分原因是 NSImage 是 AppKit,而 appscript 仅链接到 Foundation;部分原因是苹果事件的这一领域的使用没有得到很好的规范。理论上,与图像相关的 AEDES 应该包含一个标准的位图数据块,但 ISTR 在处理 iTunes 艺术品时会遇到 PICT 标头的各种麻烦。很乱。

NSData 没有桥接,因为在没有有意义的描述符类型的情况下将数据打包到 AEDES 中基本上是没有意义的。如果要打包 NSData 实例,请使用 +[NSAppleEventDescriptor DescriptorWithDescriptorType:data:]

另请查看 artwork 类的 raw data 属性。这是后来添加的,可能包含更合理形式的图像数据。

哦,看一下 EyeTunes 框架;它不像使用 AppleScript/appscript 那样灵活或高效,但我认为它包含将 NSImage 桥接到 AEDescs 的代码。

Appscript doesn't bridge NSImage, in part because NSImage is AppKit and appscript links against Foundation only; in part because this area of Apple events usage is not well specced. In theory, image-related AEDescs should contain a standard block of bitmap data, but ISTR various hassles with PICT headers when dealing with iTunes artworks. It's messy.

NSData isn't bridged because packing data into an AEDesc without a meaningful descriptor type is largely pointless. If you want to pack an NSData instance, use +[NSAppleEventDescriptor descriptorWithDescriptorType:data:].

Also take a look at the artwork class's raw data property. That's a later addition and might contain image data in a more sensible form.

Oh, and take a look at the EyeTunes framework; it's not as flexible or efficient as using AppleScript/appscript, but I think it includes code for bridging NSImage to AEDescs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文