Closed JPorter44 closed 2 years ago
I've not tried encoding with UTIF.js, so I'm making a guess here: Tag 254 is valid per the TIFF spec (NewSubfileType), but if UTIF.js is complaining about it you might try removing it from idf
before calling UTIF.encodeImage(...)
. I'd try calling delete idf.t254
before UTIF.encodeImage(...)
. Does that work?
@johnthad I tried removing that which then caused me to have to delete like 10 more tags. In the end it didn't work because I was ending up with files that were 1KB large and blank/corrupted. I believe my issue is assuming UTIF.encodeImage(...)
keeps the existing compression. I would still like to know if it's possible to keep compression while splitting a multi-page file to single page files.
Sorry, I use UTIF.js only for decompressing and displaying in a browser. All my work writing TIFF Group IV has been with Java, most recently with Java Advanced Imaging Image I/O Tools API Core (standalone).
UTIF does not use compression during encode. Anyway adding it is not that hard. In nodeJS you can simply use this: import { deflateSync } from "zlib";
instead of pako
and have much faster performance.
The TIFF encoder in Photopea supports only basic features. You should use PNG instead of TIFF when you store images.
@photopea Problem with PNG is that it can't store layers, additional channels, or it does not support other advanced features. But I do agree that in many cases PNG can replace TIFF.
Put it into multiple PNG files, and put them into a ZIP if you need just one file.
@photopea Maybe that could work for JPorter44 or johnthad but in my case I wish I could ¯_(ツ)_/¯ ...because then you have problem that you need to stack and merge those files in correct order and offset.. because you want to edit file later. So then you have to add info into zip what to do with those files and write plugin that will compose it together. So you are inventing custom propriatary file format. Which might not be necessary since that already exists and has some support. ...so I made advanced Tiff encoder myself. And I can also say that adding compression into UTIF is not that much work and will make it like 4 times smaller files... if anyone wants to implement.
When attempting to split a multi-page tiff I'm running into an error.
unknown type of tag: 254 at Object.push../node_modules/utif/UTIF.js.UTIF._writeIFD (UTIF.js:961) at Object.push../node_modules/utif/UTIF.js.UTIF.encode (UTIF.js:74) at Object.push../node_modules/utif/UTIF.js.UTIF.encodeImage (UTIF.js:57)
I'm successfully converting any tiffs that aren't Group4 compression to PNGs with UPNG. I would like to be able to split multi-page Group4 compressed tiffs into multiple single page group4 compressed tiffs. Is this possible or am I doing something wrong? Here is an example of my code where I am attempting to do this. The file variable is a javascript File object.