]> git.sesse.net Git - qscale/blob - qscale.c
Move JPEG saving into libqscale. Hooray, we have a usable lib!
[qscale] / qscale.c
1 /*
2  * qscale: Quick, high-quality JPEG-to-JPEG scaler.
3  * Copyright (C) 2008 Steinar H. Gunderson <sgunderson@bigfoot.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, version 2 of the License.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
17  */
18
19 #include <stdio.h>
20 #include <string.h>
21 #include <stdlib.h>
22 #include "jpeglib.h"
23 #include "libqscale.h"
24
25 int main(int argc, char **argv)
26 {
27         /* user-settable parameters */
28         unsigned nominal_w = atoi(argv[1]);
29         unsigned nominal_h = atoi(argv[2]);
30         unsigned samp_h0 = 2, samp_v0 = 2;
31         unsigned samp_h1 = 1, samp_v1 = 1;
32         unsigned samp_h2 = 1, samp_v2 = 1;
33         unsigned jpeg_quality = 85;
34         /* end */
35
36         qscale_img *img = qscale_load_jpeg_from_stdio(stdin);
37         qscale_img *scaled = qscale_scale(img, nominal_w, nominal_h, samp_h0, samp_v0, samp_h1, samp_v1, samp_h2, samp_v2, LANCZOS);
38         qscale_destroy(img);
39         qscale_save_jpeg_to_stdio(scaled, stdout, jpeg_quality, SEQUENTIAL);
40
41         return 0;
42 }
43