Skip to content

Instantly share code, notes, and snippets.

@smcl
Last active December 11, 2015 21:09
Show Gist options
  • Save smcl/4660220 to your computer and use it in GitHub Desktop.
Save smcl/4660220 to your computer and use it in GitHub Desktop.
dcraw (http://www.cybercom.net/~dcoffin/dcraw/) patch to accept files received from stdin. More information at http://blog.mclemon.cz/dcraw-and-stdin
--- dcraw.c 2013-01-29 00:18:05.000000000 +0100
+++ dcraw.c 2013-01-29 00:17:54.000000000 +0100
@@ -9278,7 +9278,7 @@
}
if (use_camera_matrix < 0)
use_camera_matrix = use_camera_wb;
- if (arg == argc) {
+ if (arg == argc && !read_from_stdin) {
fprintf (stderr,_("No files to process.\n"));
return 1;
}
@@ -9294,6 +9294,23 @@
}
#endif
}
+
+ if (read_from_stdin) {
+ char buf[BUFSIZ] = {0};
+ size_t bytes_read;
+ char filename[L_tmpnam];
+ tmpnam(filename);
+ FILE *tf = fopen(filename, "wb");
+ do {
+ bytes_read = fread( buf, 1, BUFSIZ, stdin );
+ fwrite(buf, 1, bytes_read, tf);
+ fflush(tf);
+ } while (bytes_read == BUFSIZ);
+ fclose(tf);
+ argv[--arg] = filename;
+ }
+
for ( ; arg < argc; arg++) {
status = 1;
raw_image = 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment