libexif库介绍

      libexif是一个用于解析、编辑和保存EXIF数据的库。它支持EXIF 2.1标准(以及2.2中的大多数)中描述的所有EXIF标签。它是用纯C语言编写的,不需要任何额外的库。源码地址:https://github.com/libexif/libexif ,最新发布版本为0.6.24,它的license为LGPL-2.1。

      EXIF全称为Exchangeable Image File format,可交换图像文件格式是专门为数码相机的照片设定的文件格式,可以记录数码照片的属性信息和拍摄数据EXIF可以附加于JPEG、TIFF、RIFF等文件之中,为其增加有关数码相机拍摄信息的内容和索引图或图像处理软件的版本信息。EXIF信息是可以被任意编辑的,因此只有参考的功能。
      EXIF信息以0xFFE1作为开头标记,后两个字节表示EXIF信息的长度。所以EXIF信息最大为64kB,而内部采用TIFF格式。

      libexif在Windows和Linux上编译过程:

      从https://github.com/libexif/libexif.git clone源码,然后切换到tag v0.6.24,执行:git checkout v0.6.24

      1.Linux上编译:

      (1).需要先安装依赖,执行如下命令:

sudo apt install autoconf autopoint libtool

      (2).编译源码,依次执行如下命令:

autoreconf -i
./configure --prefix=${PWD}/install --disable-docs
make
make install

      编译完成后在install目录下,会生成include、lib、share三个目录。

      2.Windows上编译:

      (1).新建libexif工程,参考Linux下生成的libexif.a中的文件,将相关文件添加到工程中;

      (2).将Linux下生成的config.h文件做调整并添加到libexif工程中,调整后的config.h内容如下:

/* config.h.  Generated from config.h.in by configure.  */
/* config.h.in.  Generated from configure.ac by autoheader.  *//* Define to 1 if translation of program messages to the user's nativelanguage is requested. */
/* #undef ENABLE_NLS */#define GETTEXT_PACKAGE "libexif-12"#if defined(_MSC_VER)#  pragma warning(push)#  pragma warning(disable: 4127) // warning C4127: Conditional expression is constant#include <BaseTsd.h>typedef SSIZE_T ssize_t;
#endif/* Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in theCoreFoundation framework. */
/* #undef HAVE_CFLOCALECOPYCURRENT *//* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue inthe CoreFoundation framework. */
/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE *//* Define if the GNU dcgettext() function is already present or preinstalled.*/
/* #undef HAVE_DCGETTEXT *//* Define to 1 if you have the <dlfcn.h> header file. */
/* #undef HAVE_DLFCN_H *//* Define if the GNU gettext() function is already present or preinstalled. */
/* #undef HAVE_GETTEXT *//* Define if you have the iconv() function and it works. */
/* #undef HAVE_ICONV *//* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1/* Define to 1 if you have the `localtime_r' function. */
/* #undef HAVE_LOCALTIME_R *//* Define to 1 if you have localtime_s() */
#define HAVE_LOCALTIME_S 1/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1/* Define to 1 if you have the <stdio.h> header file. */
#define HAVE_STDIO_H 1/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1/* Define to 1 if you have the <strings.h> header file. */
/* #undef HAVE_STRINGS_H *//* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1/* Define to 1 if you have the <unistd.h> header file. */
/* #undef HAVE_UNISTD_H *//* Define as const if the declaration of iconv() needs const. */
/* #undef ICONV_CONST *//* Define to the sub-directory where libtool stores uninstalled libraries. */
//#define LT_OBJDIR ".libs/"/* Name of package */
#define PACKAGE "libexif"/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "libexif-devel@lists.sourceforge.net"/* Define to the full name of this package. */
#define PACKAGE_NAME "EXIF library"/* Define to the full name and version of this package. */
#define PACKAGE_STRING "EXIF library 0.6.24"/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libexif"/* Define to the home page for this package. */
#define PACKAGE_URL "https://libexif.github.io/"/* Define to the version of this package. */
#define PACKAGE_VERSION "0.6.24"/* Define to 1 if all of the C90 standard headers exist (not just the onesrequired in a freestanding environment). This macro is provided forbackward compatibility; new code need not use it. */
#define STDC_HEADERS 1/* Version number of package */
#define VERSION "0.6.24"/* Number of bits in a file offset, on hosts where this is settable. */
/* #undef _FILE_OFFSET_BITS *//* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES *//* Define to `__inline__' or `__inline' if that's what the C compilercalls it, or to nothing if 'inline' is not supported under any name.  */
#ifndef __cplusplus
/* #undef inline */
#endif

      (3).将Linux上生成的_stdint.h文件也添加到此工程中;

      (4).编译工程生成libexif.lib静态库。

      对带有exif信息的jpg图像生成缩略图的测试代码如下:

int test_libexif_thumbnail()
{// reference: https://github.com/libexif/libexif/blob/master/contrib/examples/thumbnail.c// Create an ExifLoader object to manage the EXIF loading processExifLoader* l = exif_loader_new();if (!l) {std::cerr << "Error: fail to exif_loader_new\n";return -1;}#ifdef _MSC_VERconstexpr char* jpg_name{ "../../../test_images/exif.jpg" };
#elseconstexpr char* jpg_name{ "test_images/exif.jpg" };
#endif// Load the EXIF data from the image fileexif_loader_write_file(l, jpg_name);// Get a pointer to the EXIF dataExifData* ed = exif_loader_get_data(l);if (!ed) {std::cerr << "Error: fail to exif_loader_get_data\n";return -1;}// The loader is no longer needed--free itexif_loader_unref(l);// Make sure the image had a thumbnail before trying to write itif (ed->data && ed->size) {std::cout << "exif data size: " << ed->size << "\n";char thumb_name[1024];snprintf(thumb_name, sizeof(thumb_name), "%s_thumb.jpg", jpg_name);FILE* thumb = fopen(thumb_name, "wb");if (!thumb) {std::cerr << "Error: fail to fopen: " << thumb_name << "\n";return -1;}// Write the thumbnail image to the filefwrite(ed->data, 1, ed->size, thumb);fclose(thumb);}exif_data_unref(ed);return 0;
}

      Windows上和Linux上的执行结果如下图所示:

      GitHub:https://github.com/fengbingchun/OpenCV_Test

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/327741.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【v8漏洞利用模板】starCTF2019 -- OOB

文章目录 前言参考题目环境配置漏洞分析 前言 一道入门级别的 v8 题目&#xff0c;不涉及太多的 v8 知识&#xff0c;很适合入门&#xff0c;对于这个题目&#xff0c;网上已经有很多分析文章&#xff0c;笔者不再为大家制造垃圾&#xff0c;仅仅记录一个模板&#xff0c;方便…

TYPE-C接口取电芯片介绍和应用场景

随着科技的发展&#xff0c;USB PDTYPE-C已经成为越来越多设备的充电接口。而在这一领域中&#xff0c;LDR6328Q PD取电芯片作为设备端协议IC芯片&#xff0c;扮演着至关重要的角色。本文将详细介绍LDR6328Q PD取电芯片的工作原理、应用场景以及选型要点。 一、工作原理 LDR63…

2024年天津体育学院专升本专业考试体育教育专业素质测试说明

天津体育学院2024年高职升本科招生专业考试体育教育专业素质测试说明 一、测试内容 100米跑、立定跳远、原地推铅球 二、考试规则 1.100米跑可穿跑鞋&#xff08;短钉&#xff09;&#xff0c;起跑采用蹲踞式。抢跑个人累计犯规两次&#xff0c;取消本项考试资格&#xff0c…

解决使用localhost或127.0.01模拟CORS失效

解决使用localhost或127.0.01模拟CORS失效 前言问题发现问题解决 前言 CORS (Cross-Origin Resource Sharing) 指的是一种机制&#xff0c;它允许不同源的网页请求访问另一个源服务器上的某些资源。通常情况下&#xff0c;如果 JavaScript 代码在一个源中发起了 AJAX 请求&…

css的一些属性

我们在写项目的时候&#xff0c;会遇到多种多样的样式&#xff0c;大部分都是由css来实现的&#xff0c;css可以让我们的页面更美观&#xff0c;css通常是配合HTML使用&#xff0c;代码较为简单! 下面我就给大家举几个较为常用的一些css属性。 1.CSS中怎样让元素圆角化&#…

spring boot 2升级为spring boot 3中数据库连接池druid的问题

目录 ConfigurationClassPostProcessor ConfigurationClassBeanDefinitionReader MybatisPlusAutoConfiguration ConditionEvaluator OnBeanCondition 总结 近期给了一个任务&#xff0c;要求是对现有的 spring boot 2.x 项目进行升级&#xff0c;由于 spring boot 2.x 版…

数据结构和算法-交换排序中的快速排序(演示过程 算法实现 算法效率 稳定性)

文章目录 总览快速排序&#xff08;超级重要&#xff09;啥是快速排序演示过程算法实现第一次quicksort函数第一次partion函数到第一次quicksort的第一个quicksort到第二次quicksort的第一个quicksort到第二次quicksort的第二个quicksort到第一次quicksort的第二个quicksort到第…

while猜数字实例——C++版

案例描述&#xff1a;系统随机生成一个1到100之间的数字&#xff0c;玩家进行猜测&#xff0c;如果猜错&#xff0c;提示玩家数字过大或过小&#xff0c;如果猜对恭喜玩家胜利并退出游戏。 逻辑框图&#xff1a; #include<bits/stdc.h> using namespace std; int main()…

The Planets: Mercury

靶场环境 整个靶场的环境&#xff0c;我出现了一点点问题&#xff0c;一直找不到主机的IP地址&#xff0c;后来参考了https://www.cnblogs.com/hyphon/p/16354436.html&#xff0c;进行了相关的配置&#xff0c;最后完成靶机环境的搭建&#xff01; 信息收集 # nmap -sn 192…

Linux Debian12系统gnome桌面环境默认提供截屏截图工具gnome-screenshot

一、简介&#xff1a; 在Debian12中系统gnome桌面环境默认提供一个截图捕获工具screenshot,可以自定义区域截图、屏幕截图、窗口截图和录制视频&#xff0c;截图默认保存在“~/图片/截图”路径下。 可以在应用程序中搜索screenshot,如下图&#xff1a; 也可以在桌面右上角找到…

mysql之视图执行计划

一.视图 1.1视图简介 1.2 创建视图 1.3视图的修改 1.4视图的删除 1.5查看视图 二.连接查询案例 三.思维导图 一.视图 1.1视图简介 虚拟表&#xff0c;和普通表一样使用 MySQL中的视图&#xff08;View&#xff09;是一个虚拟表&#xff0c;其内容由查询定义。与实际表不…

DevSecOps 工具:初学者指南

DevSecOps 是开发、安全和运营的融合&#xff0c;标志着软件开发的范式转变&#xff0c;在整个软件开发生命周期 (SDLC)中无缝集成安全性。 这种方法标志着不再将安全视为开发过程中的一个阶段。除了DevSecOps 的核心原则和最佳实践之外&#xff0c;特定工具也是实施和强化安全…