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 #include "multipageconverter.h"
25 
MultipageConverter(QObject * parent)26 MultipageConverter::MultipageConverter(QObject *parent) :
27     QObject(parent)
28 {
29 
30 }
31 
readFile(QString fileName)32 void MultipageConverter::readFile(QString fileName)
33 {
34     int page_counter = 0;
35     QString tmpFileName;
36     Image my_image;
37 
38     m_pagesList.clear();
39 
40     for (;;) {
41         try {
42             MultipageItem mpi;
43 
44             tmpFileName = QString("%1[%2]")
45                     .arg(fileName)
46                     .arg(QString::number(page_counter));
47 
48             my_image.read(tmpFileName.toStdString());
49 
50             mpi.w = my_image.columns();
51             mpi.h = my_image.rows();
52 
53             mpi.xres = my_image.xResolution();
54             mpi.yres = my_image.yResolution();
55 
56             mpi.depth = my_image.depth();
57 
58             m_pagesList << mpi;
59 
60             page_counter++;
61         }
62         catch (Error& my_error) {
63 
64             break;
65         }
66         catch( Magick::WarningCoder &warning )
67         {
68 
69             break;
70         }
71         catch( Magick::Warning &warning )
72         {
73 
74             break;
75         }
76     }
77 }
78 
pages()79 QList<MultipageItem> MultipageConverter::pages()
80 {
81     return m_pagesList;
82 }
83