[英]How can I let user paste image data from the clipboard into a canvas element in Firefox in pure Javascript?
[英]How can I save image data from clipboard?
调用theClipboard
...
app.theClipboard()
...记录此数据(此处已截断):
app = Application("Preview")
app.theClipboard()
--> {
"TIFF":"<>",
"8BPS":"'8BPS'($9AB...9$)",
"GIFf":"<>",
"jp2 ":"'jp2 '($BAC...1$)",
"JPEG":"<>",
"PNGf":"'PNGf'($3F3...4$)",
"BMP ":"'BMP '($ABA...F$)",
"TPIC":"'TPIC'($FAB...3$)"
}
此代码在第一行失败...
app.make({
new: 'document', // type : The class of the new object.
at: Path(`/Users/Samsung USB/file_name.png`), // Does png imply type?
withData: app.theClipboard()['PNGf'] // If val is a string, how to convert?
})
同
Error: Can't convert types.
在标准JavaScript中,我希望能够使用
app.theClipboard()['PNGf']
检索记录的对象中的数据,但脚本将忽略它。
我可以在剪贴板上记录数据类型:
console.log(typeof quickTime.theClipboard())
/* object */
console.log(typeof quickTime.theClipboard()['PNGf'])
/* string */
theClipboard
采用as
选项(可能旨在将其字符串as
类型),但是我不知道有效值(例如'document','item','image','PNGf'、?):
console.log(app.theClipboard({ as: 'document' }))
// --> Error -1700: Can't convert types.
如果它通过JXA要求ObjC,那就足够了。
这应该是一个问题,其中app.theClipboard()
返回的变量类型与app.theClipboard()
所需的类型不withData
。 您应该先检查变量的类型,然后尝试将其转换为所需的类型。
希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.