Google
Web alhem.net
Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

fiximage.cpp

Go to the documentation of this file.
00001 00006 /* 00007 Copyright (C) 2004 Anders Hedstrom 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License 00011 as published by the Free Software Foundation; either version 2 00012 of the License, or (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program; if not, write to the Free Software 00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 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); // file=>file 00064 if (!strncmp(cmd,image.filename.c_str(),image.filename.size())) 00065 { 00066 pa.getword(); // type 00067 pa.getword(cmd); // geometry XxY 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

Generated on Sat Feb 12 00:14:56 2005 for IBank by doxygen 1.3.7