Skip to content

Instantly share code, notes, and snippets.

View wangweixuan's full-sized avatar

Wang Weixuan wangweixuan

  • Peking University
  • China
View GitHub Profile
@mwender
mwender / impbcopy.m
Last active June 20, 2024 09:20
Command line copy an image file to the clipboard in Mac OS X. See first comment for install instructions.
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <unistd.h>
BOOL copy_to_clipboard(NSString *path)
{
// http://stackoverflow.com/questions/2681630/how-to-read-png-image-to-nsimage
NSImage * image;
if([path isEqualToString:@"-"])
{
// http://caiustheory.com/read-standard-input-using-objective-c