Re: NSImage to JPEG file?

2019-01-16 Thread Carl Hoefs
Thanks Wim and Gerd. It was the NSData tie-in I didn't know. (I was expecting 
NSImage to have innate export capabilities, but this works too.)

-Carl


> On Jan 16, 2019, at 7:56 AM, Wim Lewis  wrote:
> 
> On Tue, Jan 15, 2019 at 08:10:58PM -0700, Carl Hoefs wrote:
>> Using NSBitmapImageRep, is it possible to write the JPEG representation out 
>> to a .JPG file on disk?
> 
> The normal way is to get the JPEG representation as a NSData and then 
> write that NSData to disk using (e.g.) -writeToFile:options:error:.
> 
> The ImageIO functions allow you to stream the data to disk (instead of 
> creating a complete representation in memory before writing), which can 
> be more efficient, but in my experience this is rarely a concern.
> 

___

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


Re: NSImage to JPEG file?

2019-01-16 Thread Jens Alfke


> On Jan 16, 2019, at 8:32 AM, Carl Hoefs  
> wrote:
> 
> It was the NSData tie-in I didn't know. (I was expecting NSImage to have 
> innate export capabilities

That would be poor API design. If it had -writeToFile, then it would also need 
-writeToStream:, -writeToFileHandle:, -writeToFileDescriptor:, 
-writeToNSURLSessionDataDelegate:, etc.
Providing the data itself means you can then use existing APIs on other classes 
to put the data anywhere you want.

—Jens
___

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


Re: NSImage to JPEG file?

2019-01-16 Thread Carl Hoefs


> On Jan 16, 2019, at 10:43 AM, Jens Alfke  wrote:
> 
>> On Jan 16, 2019, at 8:32 AM, Carl Hoefs > > wrote:
>> 
>> It was the NSData tie-in I didn't know. (I was expecting NSImage to have 
>> innate export capabilities
> 
> That would be poor API design. If it had -writeToFile, then it would also 
> need -writeToStream:, -writeToFileHandle:, -writeToFileDescriptor:, 
> -writeToNSURLSessionDataDelegate:, etc.
> Providing the data itself means you can then use existing APIs on other 
> classes to put the data anywhere you want.

But all of that would come "for free" if NSImage inherited from NSData, no?

-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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSImage to JPEG file?

2019-01-16 Thread Greg Weston

>> That would be poor API design. If it had -writeToFile, then it would also 
>> need -writeToStream:, -writeToFileHandle:, -writeToFileDescriptor:, 
>> -writeToNSURLSessionDataDelegate:, etc.
>> Providing the data itself means you can then use existing APIs on other 
>> classes to put the data anywhere you want.
> 
> But all of that would come "for free" if NSImage inherited from NSData, no?

No. Because there’s no guarantee that the “data” that define an NSImage - or 
its representation(s) - conform to any specific commodity format.
___

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


Re: NSImage to JPEG file?

2019-01-16 Thread Jens Alfke


> On Jan 16, 2019, at 9:59 AM, Carl Hoefs  
> wrote:
> 
> But all of that would come "for free" if NSImage inherited from NSData, no?

Well, that wouldn’t make sense, because an NSImage isn’t a piece of data. It 
can have multiple data representations (JPEG, PNG, PDF…) and it might not have 
any at all if it was created directly in-memory with a pixmap. It’s a thing 
that can create a data representation.

—Jens
___

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