libexif库介绍

news2024/9/26 5:17:20

      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 native
   language 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 the
   CoreFoundation framework. */
/* #undef HAVE_CFLOCALECOPYCURRENT */

/* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in
   the 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 ones
   required in a freestanding environment). This macro is provided for
   backward 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 compiler
   calls 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 process
	ExifLoader* l = exif_loader_new();
	if (!l) {
		std::cerr << "Error: fail to exif_loader_new\n";
		return -1;
	}

#ifdef _MSC_VER
	constexpr char* jpg_name{ "../../../test_images/exif.jpg" };
#else
	constexpr char* jpg_name{ "test_images/exif.jpg" };
#endif

	// Load the EXIF data from the image file
	exif_loader_write_file(l, jpg_name);

	// Get a pointer to the EXIF data
	ExifData* 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 it
	exif_loader_unref(l);
	
	// Make sure the image had a thumbnail before trying to write it
	if (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 file
		fwrite(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.coloradmin.cn/o/1364271.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

topsis算法

TOPSIS &#xff08;Technique for Order Preference by Similarity to an Ideal Solution &#xff09;模型中文叫做“逼近理想解排序方法”&#xff0c;是根据评价对象与理想化目标的接近程度进行排序的方法&#xff0c;是一种距离综合评价方法。基本思路是通过假定正、负理想…

C#,数值计算,基础函数——任意位数π的数值算法源程序与数据可视化

对于数学常数 PI 后面位数的计算与追求&#xff0c;是数学家与计算机科学家们乐此不疲的游戏。 一、圆周率PI简史 圆周率&#xff08;Pi&#xff09;是圆的周长与直径的比值&#xff0c;一般用希腊字母π表示&#xff0c;是一个在数学及物理学中普遍存在的数学常数。π也等于圆…

关于图像分割任务中按照比例将数据集随机划分成训练集和测试集

1. 前言 之前写了分类和检测任务划分数据集的脚本&#xff0c;三大任务实现了俩&#xff0c;基于强迫症&#xff0c;也实现一下图像分割的划分脚本 分类划分数据&#xff1a;关于图像分类任务中划分数据集&#xff0c;并且生成分类类别的josn字典文件 检测划分数据&#xff…

如何计算ThreadLocal对象的hash值?【ThreadLocal技术】(含AtomicInteger的介绍)

如何计算ThreadLocal对象的hash值&#xff1f; 一、前置知识二、问题三、剖析源码&#xff1a;如何计算ThreadLocal对象的hash值&#xff1f;1、源码1.1 咱先得知道nextHashCode的起始值1.1.1 那就要先了解AtomicInteger创建AtomicInteger原子的增减操作原子的加法操作原子的获…

对Tor的去匿名化攻击的调查

文章信息 论文题目&#xff1a;De-Anonymisation Attacks on Tor: A Survey 期刊&#xff08;会议&#xff09;&#xff1a; IEEE Communications Surveys & Tutorials 时间&#xff1a;2021 级别&#xff1a;中科院1区&#xff08;IF&#xff1a;35.6&#xff09; 文章链…

Python 面向对象之反射

Python 面向对象之反射 【一】概念 反射是指通过对象的属性名或者方法名来获取对象的属性或调用方法的能力反射还指的是在程序额运行过程中可以动态获取对象的信息(属性和方法) 【二】四个内置函数 又叫做反射函数 万物皆对象&#xff08;整数、字符串、函数、模块、类等等…

黑马程序员Java项目实战《瑞吉外卖》,轻松掌握springboot + mybatis plus开发核心技术的真java实战项目——第三部分

黑马程序员Java项目实战《瑞吉外卖》&#xff0c;轻松掌握springboot mybatis plus开发核心技术的真java实战项目——第三部分 1. 菜品管理的业务功能1.1 文件的上传和下载&#x1f647;‍♂️1.2 新增菜品1.3 接收页面提交的数据&#x1f647;‍♂️&#xff08;涉及两张表&a…

大数据技术架构

1 技术架构矩阵 大数据技术栈虽然比较多,但可以抽象为输入(数据接入)--处理(数据处理、数据分析)--输出(数据应用)。工作角色分工,数据处理以数据仓库开发人员为主,数据分析以数据分析师为主,其他所有组件、系统、技术相关归为数据平台。 2 数据源 大数据的数据来源…

媒体捕捉-iOS自定义二维码扫描功能

引言 随着iOS 7引入AV Foundation框架&#xff0c;二维码扫描功能已经成为iOS应用程序中不可或缺的一部分。现今&#xff0c;几乎每个应用都充分利用这一功能&#xff0c;为用户提供了诸如扫码登录、扫码填充等丰富多彩的便捷体验。这项技术不仅丰富了应用功能&#xff0c;也为…

我与nano实验室交流群

感兴趣的同学、朋友可以加入群聊共同学习聊天哦。 主要是工训赛、电赛、光电、集成电路等等&#xff0c;会分享一些开源代码&#xff0c;博主自己做的项目&#xff0c;自己画的PCB等等&#xff0c;包含但不限于STM32、K210、V831、机器视觉&#xff0c;机械臂&#xff0c;ROS&a…

Packet Tracer - Configure AAA Authentication on Cisco Routers

Packet Tracer - 在思科路由器上配置 AAA 认证 地址表 目标 在R1上配置本地用户账户&#xff0c;并使用本地AAA进行控制台和vty线路的身份验证。从R1控制台和PC-A客户端验证本地AAA身份验证功能。配置基于服务器的AAA身份验证&#xff0c;采用TACACS协议。从PC-B客户端验证基…

我的隐私计算学习——联邦学习(2)

笔记内容来自多本书籍、学术资料、白皮书及ChatGPT等工具&#xff0c;经由自己阅读后整理而成 &#xff08;三&#xff09;联邦学习的算子 ------------------------ 算子是什么&#xff1f;--------------------------- ​ 从广义上讲&#xff0c;对任何函数进行某一项操作都可…

【Verilog】基于Verilog的DDR控制器的简单实现(一)——初始化

在FPGA中&#xff0c;大规模数据的存储常常会用到DDR。为了方便用户使用&#xff0c;Xilinx提供了DDR MIG IP核&#xff0c;用户能够通过AXI接口进行DDR的读写访问&#xff0c;然而MIG内部自动实现了许多环节&#xff0c;不利于用户深入理解DDR的底层逻辑。 本文以美光(Micro…

Linux驱动学习—中断

1、中断基础概念 1.1 什么是中断 CPU在正常运行期间&#xff0c;由外部或者内部引起的时间&#xff0c;让CPU停下当前正在运行的程序&#xff0c;转而去执行触发他的中断所对应的程序&#xff0c;这就是中断。 响应中断的过程&#xff1a; <1>中断请求 <2>中断…

给您的应用添加弹窗

概述 在我们日常使用应用的时候&#xff0c;可能会进行一些敏感的操作&#xff0c;比如删除联系人&#xff0c;这时候我们给应用添加弹窗来提示用户是否需要执行该操作&#xff0c;如下图所示&#xff1a; 弹窗是一种模态窗口&#xff0c;通常用来展示用户当前需要的或用户必须…

cookie和session、请求转发和重定向

会话 分为有状态会话和无状态会话 在HTML中&#xff0c;"会话"一般指的是Web服务器与客户端&#xff08;通常是浏览器&#xff09;之间进行的一系列请求和响应。它是一种在网络上模拟人与人之间通信的方式&#xff0c;常见于Web应用程序中。 会话、Cookie和Sessio…

JavaScript 基础二part1.运算符:赋值、一元、比较、逻辑运算符

JavaScript 基础二 1.1 赋值运算符1.2 一元运算符自增运算符的用法&#xff1a;例题 1.3 比较运算符不同类型间的比较严格相等对 null 和 undefined 进行比较 1.4 逻辑运算符例题 1.5 运算符优先级 1.1 赋值运算符 赋值运算符&#xff1a;对变量进行赋值的运算符 已经学过的赋…

c++学习第八讲---类和对象---继承

继承&#xff1a; 使子类&#xff08;派生类&#xff09;拥有与父类&#xff08;基类&#xff09;相同的成员&#xff0c;以节约代码量。 1.继承的基本语法&#xff1a; class 子类名&#xff1a;继承方式 父类名{} &#xff1b; 例&#xff1a; class father { public:in…

李沐-《动手学深度学习》-- 01-预备知识

一、线性代数知识 1. 矩阵计算 a. 矩阵求导 ​ 当y和x分别为标量和向量时候&#xff0c;进行求导得到的矩阵形状&#xff0c;矩阵求导就是矩阵A中的每一个元素对矩阵B中的每一个元素求导 ​ 梯度指向的是值变化最大的方向 ​ 分子布局和分母布局&#xff1a; b. 常识 ax…

cube生成电机库,启用了RTOS,编译报错[0xc43ed8:5050106] in osSignalWait

cube生成电机库&#xff0c;启用了RTOS&#xff0c;编译报错[0xc43ed8:5050106&#xff0c;解决办法] in osSignalWait 1.现象 编译报错[0xc43ed8:5050106] in osSignalWait 导致链接失败 2.解决办法 将keil5的版本升级到5.18.00&#xff0c;我的版本也是5.14.00。