58 lines
1.1 KiB
C
58 lines
1.1 KiB
C
#include "../jpeg-6b/lowres.h"
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <fcntl.h>
|
|
|
|
|
|
void test_jpeglib(int argc, char** argv) {
|
|
int file_sock;
|
|
int size;
|
|
char* output = NULL;
|
|
|
|
FILE* fp;
|
|
|
|
if(argc < 3) {
|
|
printf("%s input_file output_file\n", argv[0]);
|
|
exit(1);
|
|
}
|
|
|
|
file_sock = open(argv[1], O_RDONLY);
|
|
|
|
if (!change_res_JPEG (file_sock, &output, &size)) {
|
|
printf("Resize Failed. pwnt. \n");
|
|
close(file_sock);
|
|
exit(1);
|
|
}
|
|
|
|
if(NULL == (fp = fopen(argv[2], "w"))) {
|
|
printf("Failed to open for write\n");
|
|
free(output);
|
|
close(file_sock);
|
|
exit(1);
|
|
}
|
|
|
|
printf("%d\n", size);
|
|
|
|
|
|
// for(i = 0; i < size; i++) {
|
|
// fprintf(fp, "%c", *(output+i));
|
|
// }
|
|
|
|
fwrite(output, sizeof(char), size, fp);
|
|
fflush(fp);
|
|
|
|
|
|
free(output);
|
|
close(file_sock);
|
|
fclose(fp);
|
|
}
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
test_jpeglib(argc,argv);
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|