-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathepeg.c.in
83 lines (64 loc) · 2.34 KB
/
epeg.c.in
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/** -*- C -*-
@file
@brief Epeg JPEG Thumbnailer library
These routines are used for the Epeg library.
*/
/**
@mainpage Epeg Library Documentation
@image html epeg.png
@version 0.9.0
@author Carsten Haitzler <raster@rasterman.com>
@date 2000-2003
@section intro What is Epeg?
An IMMENSELY FAST JPEG thumbnailer library API.
Why write this? It is a convenience library API to using libjpeg to load
JPEG images destined to be turned into thumbnails of the original, saving
information with these thumbnails, retreiving it and managing to load the
image ready for scaling with the minimum of fuss and CPU overhead.
This means that it is insanely fast at loading large JPEG images
and scaling them down to tiny thumbnails. The speedup that it provides
will be proportional to the size difference between the source image
and the output thumbnail size as a count of their pixels.
It makes use of libjpeg features of being able to load an image by only
decoding the DCT coefficients needed to reconstruct an image of the size
desired. This gives a massive speedup. If you do NOT try to access the
pixels in a format other than YUV (or GRAY8 if the source is grascale),
then it also avoids colorspace conversions as well.
Using the library is very easy; look at this example:
@code
#include <stdio.h> /* for printf() */
#include <stdlib.h> /* for exit() */
#include "Epeg.h"
int main(int argc, char **argv)
{
Epeg_Image *im;
if (argc != 3) {
printf("Usage: %s input.jpg thumb.jpg\n", argv[0]);
exit(0);
}
im = epeg_file_open(argv[1]);
if (!im) {
printf("Cannot open %s\n", argv[1]);
exit(-1);
}
epeg_decode_size_set(im, 128, 96);
epeg_quality_set(im, 75);
epeg_thumbnail_comments_enable(im, 1);
epeg_file_output_set(im, argv[2]);
epeg_encode(im);
epeg_close(im);
return 0;
}
@endcode
This program exists as epeg_test.c so that you can compile this program
with as small a line as:
@verbatim
gcc epeg_test.c -o epeg_test `epeg-config --cflags --libs`
@endverbatim
It is a very simple library that just makes life easier when trying to
generate lots of thumbnails for large JPEG images as quickly as possible.
Your milage may vary, but it should save you lots of time and effort in
using libjpeg in general.
@todo Check all input parameters for sanity.
@todo Actually report error conditions properly.
*/