Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Determine compression used on Tiff file

New Here ,
May 18, 2020 May 18, 2020

I have been tasked with creating a script that determines the compression used in existing files and then resaving only those that are not using LZW.  I cannot seem to find a way to determine the current files compression.  

TOPICS
Actions and scripting
3.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
May 19, 2020 May 19, 2020

Perhaps reading the input file list as binary data and or hex and searching the content for the files that don't use the TIFF tag for LZW compression... I have seen similar tricks in Bridge scripting when looking for other specific data embedded in the file, but can't help much beyond that.

 

ExifTool can easily find the compression method used in a TIFF file, for example for a file with LZW:

 

Compression = 5
Tag 0x0103 (2 bytes, int16u[1]):
0042: 00 05

 

So the data must be there, it would be easy enough for ExifTool to flag these images using a label or rating or other metadata, however, this is far from ideal.

 

https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577413_pgfId-1035272

 

Tag

259

Name

Compression

Photoshop Reads

1 (uncompressed), 2 (CCITT), 5 (LZW), 7 (JPEG), 8 (ZIP), 32773 (PackBits)

Photoshop Writes

1, 5, 7, 8

 

Good luck!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 20, 2020 May 20, 2020

Was hoping to keep the script inside photoshop instead of having to have some sort of handshake with Bridge.  I had seen the article mentioned, and are using it to get the Tranparency flag, but don't see in the TIFF data how to get Tag 259.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 20, 2020 May 20, 2020

I was suggesting doing similar/same directly in Photoshop, I was just using Bridge as an example as that is where I have seen this technique used.

 

Here is one for Photoshop:

 

https://community.adobe.com/t5/photoshop/get-transparency-status-on-tiff-images/td-p/9270519?page=1

 

I don't know either, this is above my pay grade. I'm hoping that somebody else can join in the discussion.

 

(TIFF Tag) 259 can also be expressed in hex as 0x0103.

 

ExifTool can find this compression tag and other compression tags in the file, I'm sure that Photoshop can too, the devil is always in the details.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
May 21, 2020 May 21, 2020
LATEST

try it for file:

 

#target photoshop
var f = new File('e:/_output/testfile.tif'),
    compression = { 1: 'uncompressed', 2: 'CCITT', 5: 'LZW', 7: 'JPEG', 8: 'ZIP' }

ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript')
xmpMeta = new XMPFile(f.fsName, XMPConst.FILE_TIFF, XMPConst.OPEN_FOR_READ).getXMP()

alert(compression[xmpMeta.getProperty(XMPConst.NS_TIFF, 'Compression')])

 

or for opened document:

 

#target photoshop
var compression = { 1: 'uncompressed', 2: 'CCITT', 5: 'LZW', 7: 'JPEG', 8: 'ZIP' }

ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript')
xmpMeta = new XMPMeta(app.activeDocument.xmpMetadata.rawData)

alert(compression[xmpMeta.getProperty(XMPConst.NS_TIFF, 'Compression')])

 

 

 

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines