summaryrefslogtreecommitdiff
path: root/src/jpeg-utils.h
blob: 86602a2c589297c8659319c8f264c9bb7db794d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*   Cataract - Static web photo gallery generator
 *   Copyright (C) 2008 Tomas Bzatek <tbzatek@users.sourceforge.net>
 *
 *   This program is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU General Public License
 *   as published by the Free Software Foundation; either version 2
 *   of the License, or any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
#ifndef __CGG__JPEG_UTILS_H__
#define __CGG__JPEG_UTILS_H__

#include <glib.h>
#include "setup.h"

G_BEGIN_DECLS


#define SQUARED_SIMPLE_SHAVE_AMOUNT 5  /* percent */

/*  EXIF data known keys  */
#define EXIF_APERTURE           "Exif.Photo.FNumber"
#define EXIF_CAMERA_MODEL       "Exif.Image.Model"
#define EXIF_DATETIME           "Exif.Photo.DateTimeOriginal"
#define EXIF_EXPOSURE           "Exif.Photo.ExposureTime"
#define EXIF_FLASH              "Exif.Photo.Flash"
#define EXIF_FOCAL_LENGTH       "Exif.Photo.FocalLength"
#define EXIF_ISO                "Exif.Photo.ISOSpeedRatings"
#define EXIF_IMAGE_DESCRIPTION  "Exif.Image.ImageDescription"
#define EXIF_ARTIST             "Exif.Image.Artist"
#define EXIF_COPYRIGHT          "Exif.Image.Copyright"
#define EXIF_COMMENT            "Exif.Photo.UserComment"
#define EXIF_CANON_CAMERA_TEMP  "Exif.CanonSi.CameraTemperature"
#define IPTC_COPYRIGHT          "Iptc.Application2.Copyright"
#define IPTC_CAPTION            "Iptc.Application2.Caption"
#define IPTC_AUTHOR             "Iptc.Application2.Byline"
#define JPEG_COMMENT            "Jpeg.Comment"


typedef struct ExifData ExifData;


/*
 *   EXIF and IPTC info retrieval, keeps the source file open until freed
 */
ExifData * read_exif (const gchar *filename);
void exif_data_free (ExifData *data);

/*
 *   Retrieves the value of the specified key or NULL if the key does not exist.
 *   The key argument belongs to Exiv2 namespace - see http://exiv2.org/tags.html
 *
 *   The get_exif_data_fixed() function does some pretty printing for selected keys.
 */
gchar * get_exif_data (ExifData *exif, const gchar *key);
gchar * get_exif_data_fixed (ExifData *exif, const gchar *key);

/*
 *   Returns TRUE if the image contains the key specified
 */
gboolean exif_has_key (ExifData *exif, const gchar *key);


/*
 *   resize_image: resize image pointed by src and save result to dst
 *                 - setting thumbnail flag will remove all profiles and optimize for size
 */
gboolean resize_image (const gchar *src, const gchar *dst,
                       unsigned long size_x, unsigned long size_y,
		       int quality,
		       gboolean thumbnail,
		       ThumbnailSquareType squared_thumbnail_type,
		       gboolean autorotate);

/*
 *   get_image_sizes: retrieve image dimensions
 */
void get_image_sizes (const gchar *img,
                      unsigned long *width, unsigned long *height,
                      gboolean autorotate);

/*
 *   calculate_sizes: calculate maximal image sizes within specified limits keeping aspect ratio
 */
void calculate_sizes (const unsigned long max_width, const unsigned long max_height,
		      unsigned long *width, unsigned long *height);

/*
 *   modify_exif: - strip thumbnail stored in EXIF table
 *                - add copyright to Exif::Image::Copyright and Iptc::Application2::Copyright
 */
void modify_exif (const gchar *filename, gboolean strip_thumbnail, const gchar *add_copyright);


G_END_DECLS

#endif /* __CGG__JPEG_UTILS_H__ */