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.mzph.cn/news/601907.shtml

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

相关文章

计算圆弧的起始角度、终止角度和矩形信息并使用drawArc绘制圆弧

Qt中常用绘制圆弧的库函数&#xff1a; //函数原型 void QPainter::drawArc(const QRectF &rectangle, int startAngle, int spanAngle)Qt规定1约占16个像素&#xff0c;比如一个完整的圆等于360度&#xff0c;对应的像素角度就是 5760度&#xff08;16 * 360&#xff09;…

深度学习中的自动化标签转换:对数据集所有标签做映射转换

在机器学习中&#xff0c;特别是在涉及图像识别或分类的项目中&#xff0c;标签数据的组织和准确性至关重要。本文探讨了一个旨在高效转换标签数据的 Python 脚本。该脚本在需要更新或更改类标签的场景中特别有用&#xff0c;这是正在进行的机器学习项目中的常见任务。我们将逐…

基于JavaWeb+SSM+Vue家政项目微信小程序系统的设计和实现

基于JavaWebSSMVue家政项目微信小程序系统的设计和实现 源码获取入口Lun文目录前言主要技术系统设计功能截图订阅经典源码专栏Java项目精品实战案例《500套》 源码获取 源码获取入口 Lun文目录 目录 1系统概述 1 1.1 研究背景 1 1.2研究目的 1 1.3系统设计思想 1 2相关技术 2…

如何使用RESTful API构建 web 应用程序

RESTful API 是一种设计风格&#xff0c;用于构建可扩展、灵活和可维护的 web 应用程序。它是一种基于 HTTP 协议的架构风格&#xff0c;旨在提供一组规范和约束&#xff0c;以便客户端和服务器之间的通信更加简单和可预测。 RESTful API 通过使用 HTTP 动词来定义资源的操作&…

【DevOps-01]】DevOps介绍

一、简要描述 DevOps:Development & Operations的缩写,也就是开发&运维 DevOps是一个不断提高效率并且持续不断工作的过程。 核心:简化Dev和Ops团队之间的流程,使整体软件开发过程更快速。 DevOps定义: DevOps 强调的是高效组织团队之间如何通过自动化的工具协作和…

数据结构OJ实验16-选择排序与堆排序与归并排序

A. DS排序--简单选择排序 题目描述 给出一个数据序列&#xff0c;使用简单选择排序算法进行升序排序。 输入 第一行输入t&#xff0c;表示有t个测试示例 第二行输入n&#xff0c;表示第一个示例有n个数据(n>1) 第三行输入n个数据&#xff0c;都是正整数&#xff0c;数据…

MyBatis 进阶

MyBatis 进阶 复杂CURD返回设置返回类型&#xff1a;resultType返回字典映射&#xff1a;resultMap 多表查询动态SQL使⽤<<if>if>标签<trim\>标签<where\>标签<set\>标签<foreach\>标签 其他打开日志单元测试不污染数据库 复杂CURD 返回设…

docker 一些有用的操作

创建一个网络组 docker network create xxx(网络名称) docker network inspect xxx 网络的配置信息 docker network list 所有网络的列表docker部署 1 编写Dockerfile文件 2 打包镜像 docker build -t 镜像名 . 3 运行镜像 docker run -d -p 5001:5001 --net 网络名称 --na…

Model::unguard()的作用

这是在生成假数据时碰见的&#xff0c;浅查了一下 Model::unguard() 是 Laravel 框架中的一个方法&#xff0c;它的作用是取消对 Eloquent 模型的属性赋值的安全性保护。 在默认情况下&#xff0c;Laravel 的 Eloquent 模型会对属性赋值做一些安全性检查&#xff0c;例如防止…

Java:IO流详解

文章目录 基础流1、IO概述1.1 什么是IO1.2 IO的分类1.3 顶级父类们 2、字节流2.1 一切皆为字节2.2 字节输出流 OutputStream2.3 FileOutputStream类2.3.1 构造方法2.3.2 写出字节数据2.3.3 数据追加续写2.3.4 写出换行 2.4 字节输入流 InputStream2.5 FileInputStream类2.5.1 构…

LeetCode 225.用队列实现栈(详解) ૮꒰ ˶• ༝ •˶꒱ა

题目详情&#xff1a; 思路&#xff1a;1.定义两个队列用于存储栈的数据&#xff0c;其中一个为空。 2.对我们定义的栈进行入数据&#xff0c;就相当于对不为空的队列进行入数据。 3.对我们定义的栈进行删除&#xff0c;相当于取出不为空的队列中的数据放到为空的队列中&#x…

线程的6中状态

这个6中状态是Java Thread类中的枚举值中来的。 public enum State {/*** Thread state for a thread which has not yet started.*/NEW,/*** Thread state for a runnable thread. A thread in the runnable* state is executing in the Java virtual machine but it may* be…

Springboot基于注解的AOP操作

注解类 package com.example.springaop.annotation;import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target;/*** @module* @author:DUOLUONIANDAI* @DATA:20…

Java 线程池四种拒绝策略

文章目录 Java 线程池的拒绝策略 AbortPolicy 策略CallerRunsPolicy 策略DiscardPolicy 策略DiscardOldestPolicy 策略 Java 线程池的拒绝策略 Java 线程池的拒绝策略一共有四种&#xff0c;分别为AbortPolicy&#xff0c;CallerRunsPolicy&#xff0c;DiscardPolicy&#xff…

java基础之list 与set集合(ArrayList,LinkedList,HashSet,LinkedHashSet,TreeSet)

List集合 集合的概念 是一个容器,可以存放多个数据.通常用来替代数组 集合的特点 只能存放引用类型 所有集合都来自于java.util包 List、Set、Map都是接口 List的存储特点 有序、有下标、元素可以重复 常用实现类 ArrayList&#xff08;常用&#xff09; JDK1.2 底层数组…

vue之服务端渲染(SSR)

目录 一、认识 SSR二、创建一个 SSR 应用三、客户端激活四、代码结构五、第三方解决方案六、vue 提供的 SSR API1、renderToString()2、renderToNodeStream()3、pipeToNodeWritable()4、renderToWebStream()5、pipeToWebWritable()6、renderToSimpleStream()7、useSSRContext()…

web前端之css、style

目录 web前端之纯css实现的加载、steps、calc web前端之纯css实现的加载、steps、calc style /* -------平滑加载------- */ .smooth_loading {background: linear-gradient(#333333 0 0) 0 / 0% no-repeat #f5f5f5;animation: smooth_loading_animation 2s infinite linear;…

Python基础入门第八课笔记(自定义函数 lambda)

什么时候用lambda表达式&#xff1f; 当函数有一个返回值&#xff0c;且只有一句代码&#xff0c;可以用lambda简写。 2、lanbda语法 lambda 形参 : 表达式 注意&#xff1a; 1、形参可以省略&#xff0c;函数的参数在lambda中也适用 2、lambda函数能接收任何数量的参数但只能…

MySQL之视图内连接、外连接、子查询案例

目录 一.视图 1.1 含义 1.2 操作 二.案例 三.思维导图 一.视图 1.1 含义 虚拟表&#xff0c;查询方面和普通表一样使用。 1.2 操作 1.创建视图&#xff1a; create or replace view 视图名 as 查询语句&#xff1b; 2.视图的修改&#xff1a; 方式1 create or replace view …

C#-枚举

枚举类型 (enum type) 是具有一组命名常量的独特的值类型。 下面的示例声明并使用一个名为 Color 的枚举类型,该枚举具有三个常量值 Red、Green 和 Blue: using System; using System;enum Color {Red,Green,Blue }class Test {static void PrintColor(Color color){switch …