-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpjpeg.cpp
34 lines (28 loc) · 927 Bytes
/
pjpeg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
// main.cpp
// Toy Image Compressor
//
// Created by Phuc Nguyen on 07/21/20.
// Copyright © 2020 Phuc Nguyen. All rights reserved.
//
#include <iostream>
#include "pjpeg_compress.h"
#include "pjpeg_decompress.h"
using namespace std;
int main(int argc, const char * argv[]) {
if (argc < 4) {
cerr<<"Usage: "<<argv[0]<<" [-d] [low/medium/high] <input_file> <output_file>"<<endl;
cerr<<"Example:\nTo compress: "<<argv[0]<<" low input.bmp input.pjpeg"<<endl;
cerr<<"To decompress: "<<argv[0]<<" input.pjpeg decompressed.bmp"<<endl;
}
bool decompress_mode = strcmp(argv[1], "-d") == 0;
std::string input_filename {argv[2]};
std::string output_filename {argv[3]};
if (decompress_mode) {
decompress(input_filename, output_filename);
} else {
std::string quality{argv[1]};
compress(input_filename, output_filename, quality);
}
return 0;
}