Search code examples
copencvimage-processinggocolor-profile

Read/Write ICC Profile In Images with Go and OpenCV


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.


Solution

  • 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.