1 | #ifndef THUMB_H |
---|
2 | #define THUMB_H |
---|
3 | |
---|
4 | char* checkthumb(char* path, char* file) |
---|
5 | { |
---|
6 | char* tmpstr = NULL; |
---|
7 | |
---|
8 | tmpstr = ostrcat(createpath(path, "/.Thumbnails/"), file, 1, 0); |
---|
9 | if(file_exist(tmpstr)) |
---|
10 | return tmpstr; |
---|
11 | |
---|
12 | return NULL; |
---|
13 | } |
---|
14 | |
---|
15 | void thumbthread(struct stimerthread* self) |
---|
16 | { |
---|
17 | int width = 0, height = 0; |
---|
18 | unsigned char* buf = NULL; |
---|
19 | struct queue* qe = NULL; |
---|
20 | char* thumbfile = NULL; |
---|
21 | |
---|
22 | if(self == NULL) return; |
---|
23 | |
---|
24 | debug(307, "start thumb thread"); |
---|
25 | |
---|
26 | while(self->aktion != STOP) |
---|
27 | { |
---|
28 | sleep(5); |
---|
29 | |
---|
30 | qe = getqueue(101); |
---|
31 | while(qe != NULL) |
---|
32 | { |
---|
33 | buf = loadjpg((char*)ostrcat(createpath(qe->data, "/"), qe->data1, 0, 0), &width, &height, 16); |
---|
34 | if(buf != NULL) |
---|
35 | { |
---|
36 | buf = scale(buf, width, height, 3, 100, 100, 1); |
---|
37 | if(buf != NULL) |
---|
38 | { |
---|
39 | thumbfile = ostrcat(thumbfile, (char*)qe->data, 1, 0); |
---|
40 | thumbfile = ostrcat(thumbfile, "/.Thumbnails", 1, 0); |
---|
41 | mkdir(thumbfile, 777); |
---|
42 | |
---|
43 | thumbfile = ostrcat(thumbfile, "/", 1, 0); |
---|
44 | thumbfile = ostrcat(thumbfile, (char*)qe->data1, 1, 0); |
---|
45 | |
---|
46 | debug(307, "create thumb: %s from %s/%s", thumbfile, (char*)qe->data, (char*)qe->data1); |
---|
47 | savejpg(thumbfile, 100, 100, buf); |
---|
48 | } |
---|
49 | } |
---|
50 | |
---|
51 | free(buf); buf = NULL; |
---|
52 | free(thumbfile); thumbfile = NULL; |
---|
53 | delqueue(qe, 0); |
---|
54 | qe = getqueue(101); |
---|
55 | } |
---|
56 | } |
---|
57 | |
---|
58 | debug(307, "end thumb thread"); |
---|
59 | } |
---|
60 | |
---|
61 | #endif |
---|