使用Go和OpenCV在图像中读取/写入ICC配置文件

huangapple go评论87阅读模式
英文:

Read/Write ICC Profile In Images with Go and OpenCV

问题

我正在使用Go和go-opencv包编写调整图像大小的代码。调整大小后,我写出的图像缺少原始图像的ICC配置文件。

是否有任何可以读取/写入ICC配置文件的Go或C库?目标是不使用命令行工具,而是使用Go/C库在进程内完成所有操作。我知道存在exiftool可以为我完成这个任务,但我宁愿不要调用perl脚本。

英文:

I'm writing code to resize images with Go and the go-opencv package. After the resize happens, the image that I write out is missing the ICC profile from the original image.

Are there any Go or C libraries that can read/write ICC profiles? The goal is to not use command line tools but Go/C libraries so I can do all of this within the process. I know exiftool exists and can do this for me, but I'd rather not shell out to a perl script.

答案1

得分: 2

我只知道go-iccjpeg

> 这是一个小型实用程序包,用于从JPEG缓冲区中提取**国际彩色协会(ICC)配置文件**。

import "github.com/vimeo/go-iccjpeg/iccjpeg"

iccjpeg.GetICCBuf(input io.Reader) ([]byte, error)

> 它接受一个带有JPEG的io.Reader,并从该JPEG中返回嵌入的ICC配置文件的缓冲区(如果有的话)。
如果没有,则返回一个空的缓冲区。

英文:

I only know of go-iccjpeg:

> A small utility package to extract International Color Consortium (ICC) profiles from JPEG buffers.

import "github.com/vimeo/go-iccjpeg/iccjpeg"

iccjpeg.GetICCBuf(input io.Reader) ([]byte, error)

> It takes an io.Reader with a JPEG, and returns a buffer with the embedded ICC profile from that JPEG, if there is one.
If there is not one, it returns an empty buffer.

答案2

得分: 1

经过更多的研究,我找到了libvips和go语言的绑定库

libvips不会去除任何嵌入的配置文件。这篇博文提到了这一点:

文件的加载/保存操作(如tiffload、jpegsave等)不会对颜色进行任何处理。在加载时,它们将任何遇到的ICC配置文件作为元数据附加到vips图像上,在保存时,它们将任何附加的配置文件写入文件。它们的目标是给你一个非常接近实际存储在文件中的内容,并将颜色处理留给你来安排。

英文:

After more research, I've found libvips and the go bindings.

libvips doesn't strip any embedded profiles. This blog post mentions this:

> The file load/save operations (like tiffload, jpegsave etc.) don't do anything with colour. On load they attach any ICC profiles they see to the vips image as metadata and on save they write any attached profile to the file. They aim to give you something very close to what's actually stored in the file and leave colour processing for you to arrange.

huangapple
  • 本文由 发表于 2015年1月15日 15:19:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/27958452.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定