Thanks. Appreciated.

> On 16 Jan 2019, at 9:43 am, Vince DeMarco <[email protected]> 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 <[email protected]> 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, [email protected] wrote:
>>> 
>>> Send Cocoa-dev mailing list submissions to
>>>  [email protected]
>>> 
>>> 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
>>>  [email protected]
>>> 
>>> You can reach the person managing the list at
>>>  [email protected]
>>> 
>>> 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 <[email protected]>
>>> To: Cocoa Developers <[email protected]>
>>> Subject: NSImage to JPEG file?
>>> Message-ID:
>>>  <[email protected]>
>>> 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 <[email protected]>
>>> To: Carl Hoefs <[email protected]>
>>> Cc: Cocoa Developers <[email protected]>
>>> Subject: Re: NSImage to JPEG file?
>>> Message-ID: <[email protected]>
>>> 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 <[email protected]> 
>>>> 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 ([email protected])
>>>> 
>>>> 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 [email protected]
>>> 
>>> 
>>> 
>>> ------------------------------
>>> 
>>> Message: 3
>>> Date: Mon, 14 Jan 2019 14:48:15 -0700
>>> From: Carl Hoefs <[email protected]>
>>> To: Vince DeMarco <[email protected]>
>>> Cc: Cocoa Developers <[email protected]>
>>> Subject: Re: NSImage to JPEG file?
>>> Message-ID:
>>>  <[email protected]>
>>> 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 <[email protected]> wrote:
>>>> 
>>>> Use ImageIO.
>>>> 
>>>> create a CGImageDestinationRef and add the CGImage to it.
>>>> 
>>>> Vince
>>>> 
>>>> 
>>>> 
>>>>> On Jan 14, 2019, at 12:17 PM, Carl Hoefs <[email protected]> 
>>>>> 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 ([email protected])
>>>>> 
>>>>> 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 [email protected]
>>>> 
>>> 
>>> 
>>> 
>>> ------------------------------
>>> 
>>> Message: 4
>>> Date: Mon, 14 Jan 2019 16:06:54 -0600
>>> From: Alex Zavatone <[email protected]>
>>> To: Carl Hoefs <[email protected]>
>>> Cc: Cocoa Developers <[email protected]>
>>> Subject: Re: NSImage to JPEG file?
>>> Message-ID: <[email protected]>
>>> 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 <[email protected]> 
>>>> 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 ([email protected])
>>>> 
>>>> 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 [email protected]
>>> 
>>> 
>>> 
>>> ------------------------------
>>> 
>>> Subject: Digest Footer
>>> 
>>> _______________________________________________
>>> 
>>> Cocoa-dev mailing list      ([email protected])
>>> 
>>> 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 ([email protected])
>> 
>> 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 [email protected]
> 
_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to