UTIF.js icon indicating copy to clipboard operation
UTIF.js copied to clipboard

Adding CMYK Support + adding comments

Open Calderis opened this issue 5 years ago • 4 comments

Hi,

I'm currently working on a program that is creating printing target and so I need to build CMYK tiff file (yes print industry is still based on tiff format even in 21st century).

So first, thanks for the library ! It helps a lot.

Second, I forked the repo to enhance the library on fews points (including CMYK support) so I might suggest some modification.

You can find my repo at https://github.com/Calderis/UTIF.js and test this fork through yarn add Calderis/UTIF.js#feature/cmyk-support.

Is there some rule to participate to this repo ?


In this pull request:

  • I added some comments to help me understand what's going on
  • I change few syntax for better readability and enhance calcul time
  • I added the possibility to remove default ifd tag by specifying a null value. Eg:
const tifData = UTIF.encodeImage(
  raws[currentPageIndex].data,
  pageWidth,
  pageHeight,
  {
    t338: null  <--------- Here
  }
);
  • I added support for t332 (InkSet) , t334 (NumberOfInks) ifd tag

All this allow you now to create CMYK file by changing the t262 ifd tag to 5 and removing t338 tag.

I might by looking for a LZW compression in the future.

Calderis avatar Apr 01 '20 10:04 Calderis

Hi, do you also provide a way to specify a color space for the CMYK data, or attach an ICC profile? Or do you just allow storing any channel values between 0 and 255, and the reader can interpret them however they want?

photopea avatar Apr 01 '20 10:04 photopea

It wasn't in my scope yet to attach a color space to it, since my printing target require especially to be printed without color management.

This is indeed more a way to re-use the actual code and allow you to create cmyk encoded file. There is nothing yet like storing more (or less) than 4 channels (eg: green, orange and so). Only basics. But I might be working on another day.

In the tiff specification, CMYK values are encoded from 0 to 255 by default as well.

I tried this afternoon on the LZW compression without success. I'll try another day.

Calderis avatar Apr 01 '20 18:04 Calderis

I think I will not merge it, as I think not many people conver to TIFF, and even less people convert to CMYK TIFF. It is not worth it to expand our code for that.

I really think your "printing target" should accept e.g. sRGB images and convert them to their CMYK values themselves.

If you want to add compression, add the Deflate instead of LZW. It is much better.

photopea avatar Apr 01 '20 18:04 photopea

Alright, I'll continue to develop on my fork. Don't hesitate to contact me if needed ! But tiff files are still used in the printing industry (packaging and so on) so that's still a plus to have it in your software.

I thought that LZW was more relevant since there is a lot of repeated patterns. I'll check for the deflate compression.

Just for information, by "printing target" I was speaking of something like this :

image

This is used to calibrate professionals printers. It could be and RGB or a CMYK file depending of which kind of profile we want to create after that. Those CMYK values are not interpreted by the printing software but used "as it", the main goal is to test the ink distribution (that's why it is so important not to be translated from sRGB values or another color space).

Thanks for all

Calderis avatar Apr 02 '20 07:04 Calderis