New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for old-style JPEG compression #7
Comments
UTIFF.js would probably have to call some other library for working with JPEGs. Do you actaully plan to use it in practice? Can't you convert your images to real JPEGs in some other program and then use these JPEGs instead? |
I have encountered those kinds of images in practice. It's a client-facing screen that needs TIFF support, so it's difficult to ask the user to convert it themselves. If it's beyond the scope of this library, though, I won't ask you to add it in. |
Ok, I think I can add such feature, probably by calling JPEG decoder of PDFJS. |
I was not able to use a standard JPEG decoder directly in UTIF.js. But baseline JPEG compression seems to be quite simple (see http://www.npes.org/pdf/TIFF-v6.pdf - page 95). Would you like to try and implement it? |
UTIF.decode._decodeG3 has error at line 215. is1D = ((data[boff>>3]>>((boff&7)))&1)==1; boff++; it fail if fo == 1. |
Hi @khmars ... it is probably not related to JPEG compression. Can you send me an image, where the problem occurs, to support@photopea.com BTW it is very nice to meet somebody, who understands G3 compression :) |
@photopea There are JS decoders available. One that might do the trick is available at: https://github.com/notmasteryet/jpgjs Would you please take a look? |
I know about JPG decoders. But I think that TIFF with JPG data are quite rare. It is better to convert such images into a standard JPG and use them as JPGs afterwards. |
I wish that such Tiff files were rare but they are pretty common. We have customers who have most of the Tiff files compressed using jpeg. If you use any of the big sized copier+scanners that you find in offices, those will generate such tiff if color scanning is done. |
These are probably some old scanners. Can't you batch-convert them to JPG with some utility right after scanning? What is your use case for these files and UTIF.js ? |
These are latest model scanners. And unfortunately we do not have control on source of the files. We are just building a generic image viewer. By the way jpeg tiff is default output format in many of the enterprise capture products too. So it is not a "dead "format, how much ever I wish it were. |
I don't understand JPG format well enough, to be able to connect UTIF.js with some existing JPG library. I would have to study the specification, it can take several days. Would you be interested in donating some money to the project for this new feature? Everything would be published as open-source, free to use for the whole world forever :) |
Unfortunately, it is very difficult in our org to donate. I can help in coding if required.. |
Ok, so can you try to implement it? You can make a separate library, or use parts of UTIF.js . |
I have implemented new style JPEG compression support (Technote 2) (compression flag = 7). PR is at: It needs dependency to be added on jpg.js (https://github.com/notmasteryet/jpgjs). I have not updated package.json to mention the same. Please update accordingly, and merge the PR. I have tested this only with 1 sample file. If you find any issue please let me know. |
Hi, can you send me a TIFF image, for which it is useful? |
You can download from: http://support.decos.nl/berend/DOC019.zip One more sample is available at: https://github.com/Twinside/Juicy.Pixels/raw/master/tests/tiff/quad-jpeg.tif |
Were you able to check the PR? |
@photopea any update? Would you merge the PR? |
Hi, I am very sorry, I was a little busy. I tried to use your code. It works well with "quad-jpeg.tif", but I had problems with "DOC019-JPEG7-orientation1.tif" from the archive - it seems like it does not have the table 347. Have you tested it? Also, is the compression type 6 a lot different than 7? |
Sorry, I did not check with that file. As I mentioned earlier, I tested with only 1 file. I'll check out the other one. I hope it is not type 6 (even though the filename says JPEG7). And yes, type 6 is pretty different than 7. |
@photopea I have fixed the issue. There are cases in new JPEG compression where JPEGTables might not be separately stored. I've taken care of that case now. Please take latest from the PR. |
Ok, thank you very much. We can finally close this :) |
@syvaidya I am trying to parse .CR2 files (Canon RAW photo). The format is a TIFF format and images are encoded with type 6 compression (old JPEG). So it would be really useful to have it in UTIF.js Do you know anything more about type 6? Could we use jpg.js too to parse it (maybe after some modifications - putting the content of some tags as a prefix of data, as you do now)? What do you think? |
I had started implementing support for compression type 6, but it is still work in progress. It is very complicated format compared to type 7. You can try my current implementation from: https://gist.github.com/syvaidya/fb16051f6ae9578040a0d07bef6b757d I am not getting time and so the work has stalled for past few weeks. Not sure when I can spend time on this next. |
@photopea were you able to support type 6 jpeg compression? |
I don't understand JPEG at all, so I did not have courage to start looking into it. |
Thanks @syvaidya ! You are amazing! :) I can finally close this issue after a year. |
Would it be possible to support TIFF files with old-style JPEG compression used within?
For example, the image named
b05937c07e0f3ce1bfd2c8c71b0220ec.tif
in the archive here: https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/imagetestsuite/imagetestsuite-tiff-1.00-part3.tar.gz(Taken from imagetestsuite)
The text was updated successfully, but these errors were encountered: