Skip to main content
Known Participant
March 5, 2019
Question

read tiff file and identify it's compression type using c++ (photoshop SDK)

  • March 5, 2019
  • 2 replies
  • 2112 views

Can any let me know how to read a tiff file and identify it's compression mode (LZW, JPEG, etc..) using photoshop sdk c++?

This topic has been closed for replies.

2 replies

Participant
November 28, 2023

Checks the compression of tif.

void checkCompression(TIFF* tif) {
    uint16_t compression;
    TIFFGetField(tif, TIFFTAG_COMPRESSION, &compression);

    const TIFFCodec* codec = TIFFFindCODEC(compression);
    if (codec != NULL) {
        printf("Codec for compression method %u is %s\n", compression, codec->name);
    } else {
        printf("Codec for compression method %u not found\n", compression);
    }
}

 

Tom Ruark
Inspiring
March 6, 2019

I believe a TIFF file can have multiple images in it. And a PSD (Photoshop file) has a tag for TIFF for all the interesting things.

https://www.itu.int/itudoc/itu-t/com16/tiff-fx/docs/tiff6.pdf

Adobe Photoshop File Formats Specification

sks271994Author
Known Participant
March 7, 2019

I am able to get the compression type form the meta data. which i'm currently doing. But there are cases where the meta data is not populated with this information, for e.g. If i export an art as tiff from Illustrator and open the file in photoshop the metadata is not populated with the compression type. So in order to get this info i need to save the document again in photoshop and open the saved image for processing. So I am wondering if i have any c API to retrieve the compression type, then i can have one less problem.

So Can some one post some ways to get image compression type using PSD c++ API.

Legend
March 9, 2019

Check out libtiff.