-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathppng.m
More file actions
28 lines (19 loc) · 693 Bytes
/
ppng.m
File metadata and controls
28 lines (19 loc) · 693 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#import <Cocoa/Cocoa.h>
int main(int argc, char * const argv[]) {
if (argc != 2)
return 1;
NSPasteboard *pb = [NSPasteboard generalPasteboard];
NSImage *image = [[NSImage alloc] initWithPasteboard:pb];
if (!image)
return 1;
NSData *data = [NSBitmapImageRep representationOfImageRepsInArray:[image representations]
usingType:NSBitmapImageFileTypeJPEG properties:@{NSImageCompressionFactor: @0.1}];
[image release];
if (!data)
return 1;
if (![data writeToFile:[NSString stringWithUTF8String:argv[1]] atomically:YES])
return 1;
[pb declareTypes:@[] owner:nil];
[pb release];
return 0;
}