-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmkthumbnail.cpp
107 lines (94 loc) · 2.35 KB
/
mkthumbnail.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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include "imagesource_util.h"
#include "imagesource_solid.h"
#include "imagesource_montage.h"
#include "imagesource_gaussianblur.h"
#include "imagesource_mask.h"
#include "tiffsaver.h"
#include "jpegsaver.h"
#include "util.h"
#include "progresstext.h"
#if 0
int main(int argc,char **argv)
{
try
{
for(int i=1;i<argc;++i)
{
char *tmpfn=BuildFilename(argv[i],"_tn","jpg");
char *outfn=SafeStrcat(".",tmpfn);
free(tmpfn);
ImageSource *is=ISLoadImage(argv[i]);
int w=128;
int h=128;
if((w=((is->width*h)/is->height))>128)
{
w=128;
h=(is->height*w)/is->width;
}
is=ISScaleImageBySize(is,w,h);
// build mask
ImageSource_Montage *mon=new ImageSource_Montage(IS_TYPE_GREY);
ISDataType white[]={0};
ISDataType grey[]={IS_SAMPLEMAX/2};
ImageSource *tmp;
tmp=new ImageSource_Solid(IS_TYPE_GREY,w,h,grey);
mon->Add(tmp,(128-w)/2+15,(128-h)/2+15);
tmp=new ImageSource_Solid(IS_TYPE_GREY,155,155,white);
mon->Add(tmp,0,0);
cerr << "Montage spp: " << mon->samplesperpixel << endl;
ImageSource *mask=new ImageSource_GaussianBlur(mon,8);
ISDataType black[]={0,0,0};
ISDataType bgcol[]={0xf4f4,0xf4f4,0xf4f4};
ImageSource *background=new ImageSource_Solid(IS_TYPE_RGB,mask->width,mask->height,bgcol);
ImageSource *shadow=new ImageSource_Solid(IS_TYPE_RGB,mask->width,mask->height,black);
shadow=new ImageSource_Mask(shadow,mask);
ImageSource_Montage *mon2=new ImageSource_Montage(IS_TYPE_RGB);
mon2->Add(is,(128-w)/2+13,(128-h)/2+13);
mon2->Add(shadow,0,0);
mon2->Add(background,0,0);
ProgressText p;
JPEGSaver s(outfn,RefCountPtr<ImageSource>(mon2),90);
s.SetProgress(&p);
s.Save();
free(outfn);
}
}
catch(const char *err)
{
cerr << "Error: " << err << endl;
}
return(0);
}
#endif
int main(int argc,char **argv)
{
try
{
for(int i=1;i<argc;++i)
{
char *tmpfn=BuildFilename(argv[i],"_tn","jpg");
ImageSource *is=ISLoadImage(argv[i]);
int w=1000;
int h=1000;
if((w=((is->width*h)/is->height))>1000)
{
w=1000;
h=(is->height*w)/is->width;
}
is=ISScaleImageBySize(is,w,h);
ProgressText p;
JPEGSaver s(tmpfn,RefCountPtr<ImageSource>(is),90);
s.SetProgress(&p);
s.Save();
free(tmpfn);
}
}
catch(const char *err)
{
cerr << "Error: " << err << endl;
}
return(0);
}