1 /* 2 * This file is part of Converseen, an open-source batch image converter 3 * and resizer. 4 * 5 * (C) Francesco Mondello 2009 - 2021 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * 20 * Contact e-mail: Francesco Mondello <faster3ck@gmail.com> 21 * 22 */ 23 24 #ifndef __CONVERTER_H__ 25 #define __CONVERTER_H__ 26 27 #include <QThread> 28 #include <QMutex> 29 #include <QWaitCondition> 30 #include <QDialog> 31 #include <QObject> 32 #include <Magick++.h> 33 #include <string> 34 #include <iostream> 35 36 #include "globals.h" 37 38 using namespace Magick; 39 using namespace std; 40 41 enum FlipOrientation { VERTICAL, HORIZONTAL }; 42 43 class Converter : public QThread 44 { 45 Q_OBJECT 46 public: 47 Converter(QObject *parent); 48 void reset(); 49 ~Converter(); 50 void run(); 51 52 void setInputPicture(QString fileName); 53 void setOutputPictureName(QString fileName); 54 void setFormat(QString format); 55 void setQuality(int quality); 56 void setOutputDir(QString outputDir); 57 void setResize(QString resizingStr); 58 void setRotation(double deg); 59 void setFlip(FlipOrientation orientation); 60 void setDensity(QString densityStr); 61 void setBackgroundColor(QString bg_color, bool changeBg_color); 62 void setOverwrite(bool overwrite); 63 void setNewBasename(QString newBaseName, bool ok); 64 void setResamplingFilter(IMFilterType resamplingFilter); 65 void stopProcess(); 66 67 QMutex mutex; 68 private: 69 void resize(Image &my_image); 70 void changeDensity(Image &my_image); 71 void rotate(Image &my_image); 72 void flip(Image &my_image); 73 bool writeImage(Image &my_image, QString format, int quality, QString out); 74 QString overwriteOldFileName(QString out); 75 76 QString m_fileNameIn; 77 QString m_fileNameOut; 78 QString m_format; 79 int m_quality; 80 QString m_outputDir; 81 QString m_bg_color; 82 bool m_changeBg_color; 83 double m_rotation_deg; 84 bool m_flip; 85 FlipOrientation m_orientation; 86 87 bool m_zoom; 88 bool m_overwrite; 89 bool m_allow_rename; 90 bool m_density; 91 bool m_rotation; 92 bool m_process_stopped; 93 94 int m_conv_status; // 1 = processed; 2 = jump/unchecked; -1 = Error; 95 96 QString m_renamingString; 97 98 QString resizingString; 99 QString m_densityString; 100 101 QString m_newBaseName; 102 103 QWaitCondition imageCondition; 104 105 IMFilterType m_resamplingFilter; 106 signals: 107 void nextConversion(int); 108 void requestOverwrite(QString); 109 void errorMessage(QString); 110 private slots: 111 void conversionCompleted(); 112 }; 113 114 #endif // __CONVERTER_H__ 115