digiKam
jpegutils.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2004-09-29
7  * Description : helper methods for JPEG image format.
8  *
9  * Copyright (C) 2004-2005 by Renchi Raju <renchi dot raju at gmail dot com>
10  * Copyright (C) 2006-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  * Copyright (C) 2006-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option)
17  * any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * ============================================================ */
25 
26 #ifndef DIGIKAM_JPEG_UTILS_H
27 #define DIGIKAM_JPEG_UTILS_H
28 
29 // Qt includes
30 
31 #include <QString>
32 #include <QImage>
33 
34 // Local includes
35 
36 #include "digikam_config.h"
37 #include "digikam_export.h"
38 #include "dmetadata.h"
39 #include "metaengine_rotation.h"
40 
41 namespace Digikam
42 {
43 
44 namespace JPEGUtils
45 {
46 
48 
49 class DIGIKAM_EXPORT JpegRotator
50 {
51 public:
52 
58  explicit JpegRotator(const QString& file);
59 
63  ~JpegRotator();
64 
69  void setCurrentOrientation(MetaEngine::ImageOrientation orientation);
70 
75  void setDocumentName(const QString& documentName);
76 
81  void setDestinationFile(const QString& dest);
82 
88  bool autoExifTransform();
89 
94  bool exifTransform(TransformAction action);
95 
101  bool exifTransform(const MetaEngineRotation& matrix);
102 
103 protected:
104 
105  QString m_file;
106  QString m_destFile;
107  QString m_documentName;
111 
112 protected:
113 
114  void updateMetadata(const QString& fileName, const MetaEngineRotation& matrix);
115  bool performJpegTransform(TransformAction action, const QString& src, const QString& dest);
116 
117 private:
118 
119  // Disable
120  JpegRotator(const JpegRotator&) = delete;
121  JpegRotator& operator=(const JpegRotator&) = delete;
122 };
123 
124 DIGIKAM_EXPORT bool loadJPEGScaled(QImage& image, const QString& path, int maximumSize);
125 DIGIKAM_EXPORT bool jpegConvert(const QString& src,
126  const QString& dest,
127  const QString& documentName,
128  const QString& format=QLatin1String("PNG"));
129 DIGIKAM_EXPORT bool isJpegImage(const QString& file);
130 DIGIKAM_EXPORT int getJpegQuality(const QString& file);
131 
132 } // namespace JPEGUtils
133 
134 } // namespace Digikam
135 
136 #endif // DIGIKAM_JPEG_UTILS_H
Definition: dmetadata.h:55
Definition: jpegutils.h:50
QString m_documentName
Definition: jpegutils.h:107
QSize m_originalSize
Definition: jpegutils.h:108
MetaEngine::ImageOrientation m_orientation
Definition: jpegutils.h:110
DMetadata * m_metadata
Definition: jpegutils.h:109
QString m_destFile
Definition: jpegutils.h:106
QString m_file
Definition: jpegutils.h:105
Definition: metaengine_rotation.h:42
TransformationAction
Definition: metaengine_rotation.h:54
ImageOrientation
Definition: metaengine.h:96
bool isJpegImage(const QString &file)
Definition: jpegutils.cpp:845
int getJpegQuality(const QString &file)
Definition: jpegutils.cpp:867
bool jpegConvert(const QString &src, const QString &dest, const QString &documentName, const QString &format)
Definition: jpegutils.cpp:757
MetaEngineRotation::TransformationAction TransformAction
Definition: jpegutils.h:47
bool loadJPEGScaled(QImage &image, const QString &path, int maximumSize)
Definition: jpegutils.cpp:153
MetaEngineRotation matrix(MetaEngineRotation::TransformationAction action)
Definition: metaengine_rotation.cpp:81
Definition: datefolderview.cpp:43