main.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #include "../atpch.h"
  2. #include <string.h>
  3. const char* version_info = "\nsRGB.googlecode.com sRGB色彩联盟, 给你的工作增光添彩!\n\n"
  4. "Adobe AI EPS INDD 缩略图收集工具 版权所有 2013.06 Hongwenjun (蘭公子)\n"
  5. "CorelDRAW CDR文件 缩略图收集工具 版本代号:给力就能把思想转化成软件!\n\n"
  6. ;
  7. const char* srgb_zfb = "\n请捐赠sRGB色彩联盟开源项目,给力就能把思想转化成软件!\n"
  8. "支付宝讨饭: http://me.alipay.com/srgb \n";
  9. void helpinfo(const char* exefile)
  10. {
  11. printf("%s\nUsage: %s <Adobe文件.ai> [SaveJpgFile]\n", version_info, exefile);
  12. printf("Usage: %s <Corel文件.cdr> [SavePngFile]\n", exefile);
  13. }
  14. // 全盘搜索模式导出缩略图
  15. bool everything_thumbnail(const char* adobe_corel_filename , const char* save_thumbs_file);
  16. int main(int argc , char* argv[])
  17. {
  18. const char* adobe_corel_filename = "AICS5.ai";
  19. const char* save_thumbs_file = "save_thumbs.jpeg";
  20. char tmp_filename[MAX_PATH] = {0};
  21. if (argc >= 2) {
  22. adobe_corel_filename = argv [1];
  23. strcpy(tmp_filename , GetFileBaseName(adobe_corel_filename));
  24. strcat(tmp_filename , ".Thumb.jpg");
  25. save_thumbs_file = tmp_filename;
  26. }
  27. if (argc >= 3)
  28. strcpy(tmp_filename , argv [2]);
  29. // 没有参数,全盘搜索模式导出缩略图
  30. if (argc == 1) {
  31. everything_thumbnail(adobe_corel_filename , save_thumbs_file);
  32. return 88;
  33. }
  34. // AI EPS INDD 文件导出缩略图
  35. bool ret = AdobeThumbnail(adobe_corel_filename , save_thumbs_file); // 执行
  36. if (!ret) // CorelDRAW CDR 文件导出缩略图
  37. ret = CorelThumbnail(adobe_corel_filename, save_thumbs_file);
  38. if (!ret)
  39. helpinfo(argv[0]);
  40. return 0;
  41. }
  42. bool everything_thumbnail(const char* adobe_corel_filename , const char* save_thumbs_file)
  43. {
  44. char tmp_filename[MAX_PATH] = {0};
  45. char app_path[MAX_PATH] = {0};
  46. GetAppDir(app_path);
  47. printf("%s\n", version_info);
  48. printf("全盘搜索模式开启: 请输入搜索信息关键字,调用Everything搜索文件.\n"
  49. "示例1: 2013 画册 \t" "示例2: VIP客户 设计\t" "示例3: C:\\印刷厂 \n\n"
  50. "输入您的关键字: ");
  51. string es_cmd;
  52. getline(std::cin , es_cmd);
  53. char es_exe_file[MAX_PATH] = {0};
  54. strcpy(es_exe_file, app_path);
  55. strcat(es_exe_file, "\\es.exe ");
  56. system("rd /s /q .\\Thumbs");
  57. system("md .\\Thumbs");
  58. es_cmd = string(es_exe_file) + " " + es_cmd + " > filelist.txt";
  59. int es_err = system(es_cmd.c_str());
  60. if (es_err == 0) {
  61. string filename_line;
  62. string filename_out;
  63. std::ifstream infile("filelist.txt");
  64. while (getline(infile, filename_line)) {
  65. adobe_corel_filename = filename_line.c_str();
  66. strcpy(tmp_filename , GetFileBaseName(adobe_corel_filename));
  67. filename_out = string("./Thumbs/") + tmp_filename + ".Thumb.jpg";
  68. save_thumbs_file = filename_out.c_str();
  69. // AI EPS INDD 文件导出缩略图
  70. bool ret = AdobeThumbnail(adobe_corel_filename , save_thumbs_file);
  71. if (!ret) { // CorelDRAW CDR 文件导出缩略图
  72. char savepng_filename[MAX_PATH] = {0}; // 源图是 BMP,保存png 失真少一点
  73. strncpy(savepng_filename , save_thumbs_file, strlen(save_thumbs_file) - 4);
  74. strcat(savepng_filename, ".png");
  75. ret = CorelThumbnail(adobe_corel_filename, savepng_filename);
  76. }
  77. if (ret) putchar('.');
  78. }
  79. } else {
  80. printf("\a全盘搜索模式需要调用软件: Everything\n\n请看使用说明 第5行.\n\n");
  81. system("pause");
  82. return false;
  83. }
  84. printf("\n%s\n", srgb_zfb);
  85. system("pause");
  86. string start_Thumbs_path = string("%SystemRoot%\\explorer.exe ") + app_path + string("\\Thumbs");
  87. system(start_Thumbs_path.c_str());
  88. return true;
  89. }