/* Cataract - Static web photo gallery generator * Copyright (C) 2008 Tomas Bzatek * * 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 #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 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__ */