我想将联系人的个人资料图片写入文件。
1) 如何读取 TIFF 图像?
字典描述了图像属性:image (*TIFFPicture* or missing value) : Image for person.
在字典中 TIFFPicture 是一个链接,但是当我单击它时,没有其他信息。当阅读它的价值似乎是<>
。我如何将其作为图像读取?
2)如何写TIFF图像?
将其写入文件时,应指定什么格式?字典说:[as: type class] : how to write the data: as text, data, list, etc.
如果as:
需要写入图像,应该指定什么类型?当我使用例如as: 'data'
错误是“无法转换类型”。
例子:
var app = Application.currentApplication();
app.includeStandardAdditions = true;
myPeople = Application("Contacts").people.whose({ _and: [{lastName: "Doe" },{firstName: "John"}] });
for (i in myPeople) {
person = myPeople[i];
if (person.image() == null) continue;
var data = person.image();
var file = Path("/var/tmp/test.tiff");
app.openForAccess(file, { writePermission: true });
app.setEof(file, {to:0} ); // reset length
app.write(data, {
to: file,
//as: 'data',
});
app.closeAccess(file);
// result: file with 2 bytes ("<>")
}