aboutsummaryrefslogtreecommitdiffstats
path: root/src/imagemagick.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/imagemagick.c')
-rw-r--r--src/imagemagick.c78
1 files changed, 39 insertions, 39 deletions
diff --git a/src/imagemagick.c b/src/imagemagick.c
index e327685..ada2f6e 100644
--- a/src/imagemagick.c
+++ b/src/imagemagick.c
@@ -10,53 +10,53 @@
#include "meh.h"
struct image *imagemagick_open(FILE *f){
- int tmpfd[2];
- if(pipe(tmpfd)){
- perror("pipe");
- exit(EXIT_FAILURE);
- }
+ int tmpfd[2];
+ if(pipe(tmpfd)){
+ perror("pipe");
+ exit(EXIT_FAILURE);
+ }
- int pid;
- if(!(pid = fork())){
- close(tmpfd[0]);
- int origfd = fileno(f);
- if(lseek(origfd, 0, SEEK_SET) != 0){
- perror("lseek");
- exit(EXIT_FAILURE);
- }
+ int pid;
+ if(!(pid = fork())){
+ close(tmpfd[0]);
+ int origfd = fileno(f);
+ if(lseek(origfd, 0, SEEK_SET) != 0){
+ perror("lseek");
+ exit(EXIT_FAILURE);
+ }
- char *argv[6];
+ char *argv[6];
- argv[0] = "convert";
- argv[1] = "-depth";
- argv[2] = "255";
- asprintf(&argv[3], "fd:%i", origfd);
- asprintf(&argv[4], "ppm:fd:%i", tmpfd[1]);
- argv[5] = NULL;
+ argv[0] = "convert";
+ argv[1] = "-depth";
+ argv[2] = "255";
+ asprintf(&argv[3], "fd:%i", origfd);
+ asprintf(&argv[4], "ppm:fd:%i", tmpfd[1]);
+ argv[5] = NULL;
#ifdef NDEBUG
- /* STFU OMFG */
- freopen("/dev/null", "w", stdout);
- freopen("/dev/null", "w", stderr);
+ /* STFU OMFG */
+ freopen("/dev/null", "w", stdout);
+ freopen("/dev/null", "w", stderr);
#endif
- execvp(argv[0], argv);
+ execvp(argv[0], argv);
- perror("exec");
- exit(EXIT_FAILURE);
- }else{
- close(tmpfd[1]);
- FILE *ftmp;
- if(!(ftmp = fdopen(tmpfd[0], "rb"))){
- perror("fopen");
- exit(EXIT_FAILURE);
- }
- struct image *img = netpbm.open(ftmp);
- if(!img)
- return NULL;
- fclose(f);
- return img;
- }
+ perror("exec");
+ exit(EXIT_FAILURE);
+ }else{
+ close(tmpfd[1]);
+ FILE *ftmp;
+ if(!(ftmp = fdopen(tmpfd[0], "rb"))){
+ perror("fopen");
+ exit(EXIT_FAILURE);
+ }
+ struct image *img = netpbm.open(ftmp);
+ if(!img)
+ return NULL;
+ fclose(f);
+ return img;
+ }
}
struct imageformat imagemagick = {