If somebody is interested, here are three working handlers :
--=====
on tiffFromClipToPath:thePath
-- set thePath to POSIX path of thePath
set pb to current application's NSPasteboard's generalPasteboard() -- get pasteboard
set theData to pb's dataForType:"public.tiff" -- get tiff data off pasteboard
if theData = missing value then error "No tiff data found on clipboard"
set theResult to (theData's writeToFile:thePath atomically:true)
return (theResult = 1)
end tiffFromClipToPath:
--=====
on pngFromClipToPath:thePath
-- set thePath to POSIX path of thePath
set pb to current application's NSPasteboard's generalPasteboard() -- get pasteboard
set theData to pb's dataForType:"public.png" -- get png data off pasteboard
if theData = missing value then error "No png data found on clipboard"
set theResult to (theData's writeToFile:thePath atomically:true)
return (theResult = 1)
end pngFromClipToPath:
--=====
on pngFromClipToPathAlt:thePath
-- set thePath to POSIX path of thePath
set pb to current application's NSPasteboard's generalPasteboard() -- get pasteboard
set theData to pb's dataForType:"public.tiff" -- get tiff data off pasteboard
if theData = missing value then error "No tiff data found on clipboard"
set newRep to current application's NSBitmapImageRep's imageRepWithData:theData
set theData to (newRep's representationUsingType:(current application's NSPNGFileType) |properties|:{NSTIFFCompressionNone:1})
set theResult to (theData's writeToFile:thePath atomically:true)
return (theResult = 1)
end pngFromClipToPathAlt:
The third one may help if we need to create a png file from a clipboard which contain tiff data but no png one
Yvan KOENIG (VALLAURIS, France) mercredi 27 mai 2015 15:52:44