Thanks. Appreciated. > On 16 Jan 2019, at 9:43 am, Vince DeMarco <dema...@apple.com> wrote: > > Here is code that will write it out as a PNG > > void WriteImageToPath(CGImageRef image,const char *path) > { > CGImageDestinationRef dest; > CFURLRef url; > > url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,(const > UInt8 *)path,strlen(path),0); > dest = CGImageDestinationCreateWithURL(url,CFSTR("public.png"), 1, NULL); > > CGImageDestinationAddImage(dest,image,NULL); > CGImageDestinationFinalize(dest); > CFRelease(url); > CFRelease(dest); > } > > To write it out a a jpeg change the UTI type above from public.png -> > public.jpeg > > > Its all and there should be examples. > > Vince > > >> On Jan 15, 2019, at 2:35 PM, Bruce Stephens <br...@toorak.com> wrote: >> >> Any chance to see those few lines of code for NSimage ImageIO to jpeg? >> Thanks. Bruce. >> >>> On 16 Jan 2019, at 7:00 am, cocoa-dev-requ...@lists.apple.com wrote: >>> >>> Send Cocoa-dev mailing list submissions to >>> cocoa-dev@lists.apple.com >>> >>> To subscribe or unsubscribe via the World Wide Web, visit >>> https://lists.apple.com/mailman/listinfo/cocoa-dev >>> or, via email, send a message with subject or body 'help' to >>> cocoa-dev-requ...@lists.apple.com >>> >>> You can reach the person managing the list at >>> cocoa-dev-ow...@lists.apple.com >>> >>> When replying, please edit your Subject line so it is more specific >>> than "Re: Contents of Cocoa-dev digest..." >>> >>> >>> Today's Topics: >>> >>> 1. NSImage to JPEG file? (Carl Hoefs) >>> 2. Re: NSImage to JPEG file? (Vince DeMarco) >>> 3. Re: NSImage to JPEG file? (Carl Hoefs) >>> 4. Re: NSImage to JPEG file? (Alex Zavatone) >>> >>> >>> ---------------------------------------------------------------------- >>> >>> Message: 1 >>> Date: Mon, 14 Jan 2019 13:17:41 -0700 >>> From: Carl Hoefs <newsli...@autonomy.caltech.edu> >>> To: Cocoa Developers <cocoa-dev@lists.apple.com> >>> Subject: NSImage to JPEG file? >>> Message-ID: >>> <13373da6-ece9-445d-9ff0-08a78393e...@autonomy.caltech.edu> >>> Content-Type: text/plain; CHARSET=US-ASCII >>> >>> I have a background macOS daemon process (aka Foundation-based "command >>> line tool") that needs to write out a JPEG file to local disk. The image >>> resides in an NSImage object (or alternatively, an NSData of raw RGB image >>> data). >>> >>> Short of resorting to something like libjpeg, what is the ObjC way to do >>> this? >>> >>> -Carl >>> >>> >>> >>> ------------------------------ >>> >>> Message: 2 >>> Date: Mon, 14 Jan 2019 12:26:08 -0800 >>> From: Vince DeMarco <dema...@apple.com> >>> To: Carl Hoefs <newsli...@autonomy.caltech.edu> >>> Cc: Cocoa Developers <cocoa-dev@lists.apple.com> >>> Subject: Re: NSImage to JPEG file? >>> Message-ID: <64df7de3-f45f-4205-991c-84bf7e131...@apple.com> >>> Content-Type: text/plain; CHARSET=US-ASCII >>> >>> Use ImageIO. >>> >>> create a CGImageDestinationRef and add the CGImage to it. >>> >>> Vince >>> >>> >>> >>>> On Jan 14, 2019, at 12:17 PM, Carl Hoefs <newsli...@autonomy.caltech.edu> >>>> wrote: >>>> >>>> I have a background macOS daemon process (aka Foundation-based "command >>>> line tool") that needs to write out a JPEG file to local disk. The image >>>> resides in an NSImage object (or alternatively, an NSData of raw RGB image >>>> data). >>>> >>>> Short of resorting to something like libjpeg, what is the ObjC way to do >>>> this? >>>> >>>> -Carl >>>> >>>> _______________________________________________ >>>> >>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >>>> >>>> Please do not post admin requests or moderator comments to the list. >>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com >>>> >>>> Help/Unsubscribe/Update your Subscription: >>>> https://lists.apple.com/mailman/options/cocoa-dev/demarco%40apple.com >>>> >>>> This email sent to dema...@apple.com >>> >>> >>> >>> ------------------------------ >>> >>> Message: 3 >>> Date: Mon, 14 Jan 2019 14:48:15 -0700 >>> From: Carl Hoefs <newsli...@autonomy.caltech.edu> >>> To: Vince DeMarco <dema...@apple.com> >>> Cc: Cocoa Developers <cocoa-dev@lists.apple.com> >>> Subject: Re: NSImage to JPEG file? >>> Message-ID: >>> <d46142b3-21d3-4944-9df0-a0a3003d8...@autonomy.caltech.edu> >>> Content-Type: text/plain; CHARSET=US-ASCII >>> >>> Got it working! >>> Thanks, that's the tip I needed. >>> -Carl >>> >>> >>>> On Jan 14, 2019, at 1:26 PM, Vince DeMarco <dema...@apple.com> wrote: >>>> >>>> Use ImageIO. >>>> >>>> create a CGImageDestinationRef and add the CGImage to it. >>>> >>>> Vince >>>> >>>> >>>> >>>>> On Jan 14, 2019, at 12:17 PM, Carl Hoefs <newsli...@autonomy.caltech.edu> >>>>> wrote: >>>>> >>>>> I have a background macOS daemon process (aka Foundation-based "command >>>>> line tool") that needs to write out a JPEG file to local disk. The image >>>>> resides in an NSImage object (or alternatively, an NSData of raw RGB >>>>> image data). >>>>> >>>>> Short of resorting to something like libjpeg, what is the ObjC way to do >>>>> this? >>>>> >>>>> -Carl >>>>> >>>>> _______________________________________________ >>>>> >>>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >>>>> >>>>> Please do not post admin requests or moderator comments to the list. >>>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com >>>>> >>>>> Help/Unsubscribe/Update your Subscription: >>>>> https://lists.apple.com/mailman/options/cocoa-dev/demarco%40apple.com >>>>> >>>>> This email sent to dema...@apple.com >>>> >>> >>> >>> >>> ------------------------------ >>> >>> Message: 4 >>> Date: Mon, 14 Jan 2019 16:06:54 -0600 >>> From: Alex Zavatone <z...@mac.com> >>> To: Carl Hoefs <newsli...@autonomy.caltech.edu> >>> Cc: Cocoa Developers <cocoa-dev@lists.apple.com> >>> Subject: Re: NSImage to JPEG file? >>> Message-ID: <6e8e883e-245d-43ab-88eb-ba4cd0ed9...@mac.com> >>> Content-Type: text/plain; CHARSET=US-ASCII >>> >>> I will send you something. >>> >>> Sent from my iPhone >>> >>>> On Jan 14, 2019, at 2:17 PM, Carl Hoefs <newsli...@autonomy.caltech.edu> >>>> wrote: >>>> >>>> I have a background macOS daemon process (aka Foundation-based "command >>>> line tool") that needs to write out a JPEG file to local disk. The image >>>> resides in an NSImage object (or alternatively, an NSData of raw RGB image >>>> data). >>>> >>>> Short of resorting to something like libjpeg, what is the ObjC way to do >>>> this? >>>> >>>> -Carl >>>> >>>> _______________________________________________ >>>> >>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >>>> >>>> Please do not post admin requests or moderator comments to the list. >>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com >>>> >>>> Help/Unsubscribe/Update your Subscription: >>>> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com >>>> >>>> This email sent to z...@mac.com >>> >>> >>> >>> ------------------------------ >>> >>> Subject: Digest Footer >>> >>> _______________________________________________ >>> >>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >>> >>> Do not post admin requests or moderator comments to the list. >>> Contact the moderators at cocoa-dev-admins (at) lists.apple.com >>> >>> https://lists.apple.com/mailman/listinfo/cocoa-dev >>> >>> >>> ------------------------------ >>> >>> End of Cocoa-dev Digest, Vol 16, Issue 1 >>> **************************************** >> _______________________________________________ >> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >> >> Please do not post admin requests or moderator comments to the list. >> Contact the moderators at cocoa-dev-admins(at)lists.apple.com >> >> Help/Unsubscribe/Update your Subscription: >> https://lists.apple.com/mailman/options/cocoa-dev/demarco%40apple.com >> >> This email sent to dema...@apple.com > _______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com