• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: 'Make new attachment' dilemma
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'Make new attachment' dilemma


  • Subject: Re: 'Make new attachment' dilemma
  • From: Yvan KOENIG <email@hidden>
  • Date: Wed, 27 May 2015 15:54:27 +0200

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


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: 'Make new attachment' dilemma
      • From: Shane Stanley <email@hidden>
References: 
 >Re: 'Make new attachment' dilemma (From: Brian Christmas <email@hidden>)
 >Re: 'Make new attachment' dilemma (From: Shane Stanley <email@hidden>)
 >Re: 'Make new attachment' dilemma (From: Brian Christmas <email@hidden>)
 >Re: 'Make new attachment' dilemma (From: Yvan KOENIG <email@hidden>)
 >Re: 'Make new attachment' dilemma (From: Shane Stanley <email@hidden>)
 >Re: 'Make new attachment' dilemma (From: Yvan KOENIG <email@hidden>)

  • Prev by Date: Re: 'Make new attachment' dilemma
  • Next by Date: Re: 'Make new attachment' dilemma
  • Previous by thread: Re: 'Make new attachment' dilemma
  • Next by thread: Re: 'Make new attachment' dilemma
  • Index(es):
    • Date
    • Thread