17 static void Usage (
char **argv )
19 cout <<
"Usage: " << argv[0]
20 <<
" [-density resolution] [-filter algorithm] [-geometry geometry]" 21 <<
" [-resample resolution] input_file output_file" << endl
22 <<
" algorithm - bessel blackman box catrom cubic gaussian hamming hanning" << endl
23 <<
" hermite lanczos mitchell point quadratic sample scale sinc triangle" << endl;
29 cout <<
"Argument \"" << argv[position] <<
"\" at position" << position
30 <<
"incorrect" << endl;
34 int main(
int argc,
char **argv)
51 Magick::FilterType filter(LanczosFilter);
54 ResizeAlgorithm resize_algorithm=Zoom;
57 while ((argv_index < argc - 2) && (*argv[argv_index] ==
'-'))
59 std::string command(argv[argv_index]);
60 if (command.compare(
"-density") == 0)
73 else if (command.compare(
"-filter") == 0)
76 std::string algorithm(argv[argv_index]);
77 if (algorithm.compare(
"point") == 0)
79 else if (algorithm.compare(
"box") == 0)
81 else if (algorithm.compare(
"triangle") == 0)
82 filter=TriangleFilter;
83 else if (algorithm.compare(
"hermite") == 0)
85 else if (algorithm.compare(
"hanning") == 0)
87 else if (algorithm.compare(
"hamming") == 0)
89 else if (algorithm.compare(
"blackman") == 0)
90 filter=BlackmanFilter;
91 else if (algorithm.compare(
"gaussian") == 0)
92 filter=GaussianFilter;
93 else if (algorithm.compare(
"quadratic") == 0)
94 filter=QuadraticFilter;
95 else if (algorithm.compare(
"cubic") == 0)
97 else if (algorithm.compare(
"catrom") == 0)
99 else if (algorithm.compare(
"mitchell") == 0)
100 filter=MitchellFilter;
101 else if (algorithm.compare(
"lanczos") == 0)
102 filter=LanczosFilter;
103 else if (algorithm.compare(
"bessel") == 0)
105 else if (algorithm.compare(
"sinc") == 0)
107 else if (algorithm.compare(
"sample") == 0)
108 resize_algorithm=Sample;
109 else if (algorithm.compare(
"scale") == 0)
110 resize_algorithm=Scale;
116 else if (command.compare(
"-geometry") == 0)
120 geometry=
Geometry(argv[argv_index]);
129 else if (command.compare(
"-resample") == 0)
133 resample=
Geometry(argv[argv_index]);
145 if (argv_index>argc-1)
147 std::string input_file(argv[argv_index]);
151 std::string output_file(argv[argv_index]);
154 Image image(input_file);
163 (image.
columns()*((double)resample.
x()/density.
x())+0.5),
165 (image.
rows()*((double)resample.
y()/density.
y())+0.5));
168 switch (resize_algorithm)
174 image.
scale(geometry);
178 image.
zoom(geometry);
181 image.
write(output_file);
183 catch( exception &error_ )
185 cout <<
"Caught exception: " << error_.what() << endl;
void density(const Point &density_)
void zoom(const Geometry &geometry_)
void filterType(const FilterType filterType_)
static void ParseError(int position, char **argv)
class MagickPPExport Geometry
void scale(const Geometry &geometry_)
void sample(const Geometry &geometry_)
size_t columns(void) const
static void Usage(char **argv)
int main(int argc, char **argv)
MagickPPExport void InitializeMagick(const char *path_)