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(path, "/.Thumbnails/", 0, 0); |
---|
9 | tmpstr = ostrcat(tmpstr, file, 1, 0); |
---|
10 | if(file_exist(tmpstr)) |
---|
11 | return tmpstr; |
---|
12 | |
---|
13 | free(tmpstr); |
---|
14 | return NULL; |
---|
15 | } |
---|
16 | |
---|
17 | void thumbthread(struct stimerthread* self) |
---|
18 | { |
---|
19 | int channels = 0; |
---|
20 | unsigned long width = 0, height = 0, rowbytes = 0; |
---|
21 | unsigned char* buf = NULL; |
---|
22 | struct queue* qe = NULL; |
---|
23 | char* thumbfile = NULL; |
---|
24 | |
---|
25 | if(self == NULL) return; |
---|
26 | |
---|
27 | debug(307, "start thumb thread"); |
---|
28 | |
---|
29 | while(self->aktion != STOP) |
---|
30 | { |
---|
31 | int count = 0; |
---|
32 | |
---|
33 | qe = getqueue(101); |
---|
34 | while(qe != NULL) |
---|
35 | { |
---|
36 | if(qe->data != NULL && ostrstr(qe->data, ".Thumbnails") == NULL) |
---|
37 | { |
---|
38 | char* picname = createpath(qe->data, qe->data1); |
---|
39 | buf = loadjpg(picname, &width, &height, &rowbytes, &channels, 16); |
---|
40 | free(picname); picname = NULL; |
---|
41 | |
---|
42 | if(buf != NULL) |
---|
43 | { |
---|
44 | thumbfile = ostrcat(thumbfile, (char*)qe->data, 1, 0); |
---|
45 | thumbfile = ostrcat(thumbfile, "/.Thumbnails", 1, 0); |
---|
46 | mkdir(thumbfile, 0777); |
---|
47 | |
---|
48 | thumbfile = ostrcat(thumbfile, "/", 1, 0); |
---|
49 | thumbfile = ostrcat(thumbfile, (char*)qe->data1, 1, 0); |
---|
50 | |
---|
51 | debug(307, "create thumb: %s from %s/%s", thumbfile, (char*)qe->data, (char*)qe->data1); |
---|
52 | buf = savejpg(thumbfile, width, height, channels, 100, 100, 70, buf); |
---|
53 | } |
---|
54 | } |
---|
55 | |
---|
56 | free(buf); buf = NULL; |
---|
57 | free(thumbfile); thumbfile = NULL; |
---|
58 | delqueue(qe, 0); |
---|
59 | qe = getqueue(101); |
---|
60 | if(self->aktion == STOP) break; |
---|
61 | } |
---|
62 | |
---|
63 | while(count < 6) |
---|
64 | { |
---|
65 | if(self->aktion == STOP) break; |
---|
66 | sleep(1); |
---|
67 | count++; |
---|
68 | } |
---|
69 | } |
---|
70 | |
---|
71 | delqueue(qe, 0); |
---|
72 | debug(307, "end thumb thread"); |
---|
73 | } |
---|
74 | |
---|
75 | #endif |
---|