How to write a 5+ channel TIFF?

为君一笑 提交于 2021-02-08 05:56:09

问题


I'm trying to find a library that will allow me to create tiffs with an arbitrary amount of channels such as how Photoshop allows it to happen.

Specifically, I need to write a 6 channel TIFF (CMYK w/ 2 channels to represent white), but all the libraries/scriptable tools im finding max out at RBGA.

Any ideas on how to program this?

Details on What I'd Like

From @BitBank's question below. I'd prefer to not implement the adobe tiff spec myself.

Operating environment Ubuntu/Windows Server

FOSS/Paid? Preferably OSS

Language? C/C++/C#/Golang/Python/Java


回答1:


This can be done with a number of tools (including my own company's), but the problem that you're going to run into is that the "right" solution doesn't make a whole lot of sense in TIFF land. For example, you can set the number of channels to whatever you want and set up an array of values for the extra samples tag, but you're going to use the undefined value. Then there's a question of what the photometric interpretation tag should contain? It's not CMYK and there's nothing remotely appropriate for it in the spec.

So what does PhotoShop do? Don't know off the top of my head, but I do know that there is an ICC profile tag which can contain all the information needed to define the channel information , so maybe it does that? This is the kind of decision that you can make when you are involved in creating the TIFF spec and have the engineering to support your custom extensions. You don't have that. And here's what will happen (from my point of view): your bizarre TIFFs make it out into the wild and get into the hands of one of my customers who then say, "HEY! - your software gives me funny colors/no image when I open this TIFF. I thought you supported TIFF?" And this usually comes from a customer who doesn't know that TIFF isn't one file format but is instead a bunch of different formats/compressions glommed together and when you have some university project that made a set of gray TIFFs with un-normalized floating point data for the channel values and use a completely custom, unpublished, undocumented tag set to describe the min and max values, so I waste a couple days trying to track down the source of the file and write up a sample app for the customer to normalize the channel values and standardize the file. Guh.

Very Important Advice: Don't do this.

And if you choose to ignore my Very Important Advice and do the thing, you should do the following:

  1. Document how you're customizing the TIFF contents
  2. Publish that spec publicly
  3. Publish code that generates and consumes it
  4. Set up a software tag that identifies you and your software and points to your documents so that when I get stuck having to support your extensions, I can at the very least cast aspersions on your parentage and at best have a roadmap for "fixing" your files.

Here's what I would do if I were you - split the channels up into n different gray files and bundle them with an XML file that documents how to put them together or bundle a CMYK file along with the extra channels in several separate TIFF files.



来源:https://stackoverflow.com/questions/21734675/how-to-write-a-5-channel-tiff

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!