00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
#include <mysql/mysql.h>
00024
#include <libmysqlwrapped.h>
00025
#include <libibank.h>
00026
#include <libcgi++.h>
00027
00028
00029 int main(
int argc,
char *argv[])
00030 {
00031 Database db(
"localhost",
"root",
"",
"ibank");
00032 Query q(db);
00033 Base64 bomb;
00034
00035 q.get_result(
"select * from image");
00036
while (q.fetch_row())
00037 {
00038 db::Image image(&db, &q);
00039
00040 printf(
"%s\n",image.filename.c_str());
00041 unlink(
"/tmp/tn.gif");
00042 unlink(
"/tmp/geometry");
00043
00044
while (image.image_tn.size())
00045 {
00046 std::vector<std::string>::iterator it = image.image_tn.begin();
00047 image.image_tn.erase(it);
00048 }
00049 bomb.decode_to_file(image.image_data, (
char *)image.filename.c_str());
00050 size_t x = 0;
00051 size_t y = 0;
00052 {
00053 FILE *fil;
00054
char cmd[1000];
00055 sprintf(cmd,
"%s -verbose -geometry 128 %s /tmp/tn.gif 2>/tmp/geometry",_CONVERT,image.filename.c_str());
00056 system( cmd );
00057
if ((fil = fopen(
"/tmp/geometry",
"rt")) != NULL)
00058 {
00059 fgets(cmd, 1000, fil);
00060
while (!feof(fil))
00061 {
00062 Parse pa(cmd);
00063 pa.getword(cmd);
00064
if (!strncmp(cmd,image.filename.c_str(),image.filename.size()))
00065 {
00066 pa.getword();
00067 pa.getword(cmd);
00068 {
00069 Parse pa(cmd,
"x=");
00070 x = pa.getvalue();
00071 y = pa.getvalue();
00072
break;
00073 }
00074 }
00075
00076 fgets(cmd, 1000, fil);
00077 }
00078 fclose(fil);
00079 }
00080 }
00081 bomb.encode_from_file(
"/tmp/tn.gif", image.image_tn);
00082 image.xsize = x;
00083 image.ysize = y;
00084 image.save();
00085 unlink(
"/tmp/tn.gif");
00086 unlink(
"/tmp/geometry");
00087 }
00088 q.free_result();
00089
00090 }
00091
00092