• 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: Tue, 26 May 2015 14:50:42 +0200


Le 26/05/2015 à 14:47, Shane Stanley <email@hidden> a écrit :

On 26 May 2015, at 9:39 pm, Yvan KOENIG <email@hidden> wrote:

If I understand well the question may be resumed to : 

how must we edit the instruction :

set theImage to current application's NSImage's alloc()'s initWithContentsOfFile:imagePath

so that it uses the data extracted from the clipboard.

Yes, you could change it to this:

set pb to current application's NSPasteboard's generalPasteboard() -- get pasteboard
set theData to pb's dataForType:"public.tiff" -- get tiff data off pasteboard
set theImage to current application's NSImage's alloc()'s initWithData:theData

But you already have a tiff representation, so there's no need to make an image to get another one. Then the complete handler becomes quite a bit shorter:

on jpegFromClipToPath:thePath compressFactor:compFactor -- 0.0 = max compression, 1.0 = none
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 NSJPEGFileType) |properties|:{NSImageCompressionFactor:compFactor, NSImageProgressive:false})
set theResult to (theData's writeToFile:thePath atomically:true)
return (theResult = 1)
end jpegFromClipToPath:compressFactor:

--

Thanks

I was fighting with the definitions given in XCode help.

Yvan KOENIG (VALLAURIS, France) mardi 26 mai 2015 14:50:38



 _______________________________________________
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

References: 
 >Re: 'Make new attachment' dilemma (From: Brian Christmas <email@hidden>)
 >Fwd: 'Make new attachment' dilemma (From: Brian Christmas <email@hidden>)
 >Re: 'Make new attachment' dilemma (From: Christopher Stone <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>)

  • 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