aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/imagemagick.c78
-rw-r--r--src/netpbm.c18
2 files changed, 48 insertions, 48 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 = {
diff --git a/src/netpbm.c b/src/netpbm.c
index 2c91879..dbd3d16 100644
--- a/src/netpbm.c
+++ b/src/netpbm.c
@@ -128,15 +128,15 @@ int netpbm_read(struct image *img){
img->buf[a++] = val;
}
}else if(b->format == '6'){
- if(b->maxval == 255){
- fread(img->buf, 1, left * 3, f);
- }else{
- while(left--){
- img->buf[a++] = readvalb(b);
- img->buf[a++] = readvalb(b);
- img->buf[a++] = readvalb(b);
- }
- }
+ if(b->maxval == 255){
+ fread(img->buf, 1, left * 3, f);
+ }else{
+ while(left--){
+ img->buf[a++] = readvalb(b);
+ img->buf[a++] = readvalb(b);
+ img->buf[a++] = readvalb(b);
+ }
+ }
}
img->state = LOADED;