Skip to main content
Mike_Gondek10189183
Community Expert
Community Expert
July 3, 2018
Answered

Way to check if 1000s of.tifs are saved with transparency.

  • July 3, 2018
  • 3 replies
  • 7368 views

Is there a way  to check this setting was enabled on 1000s of files? Such as with bridge, up in the filename, or even down in bottom left of window.

Opening up each file and doing a save as, is really time consuming.

    This topic has been closed for replies.
    Correct answer Stephen Marsh

    OK, here is a hack to another Adobe Bridge script to add TIFF files WITH transparency to a collection… Yes, I know you wish to locate files without transparency, but at least this is a start… Stay with me here :]

     

    Once the collection is created, apply a unique metadata entry such as a label; star rating or keyword that is not used in your files to all of the transparent images in the collection.

     

    Now when you view the images outside of the collection back in their original locations, the label or rating will be visible. You can now easily sort and isolate the files with and without the label or rating etc using the filter panel, find command, smart collections etc.

     

    Job done!

     

    // https://forums.adobe.com/thread/1990912
    // https://forums.adobe.com/message/10481093
    #target bridge    
       if( BridgeTalk.appName == "bridge" ) {    
    tiffTransparency= MenuElement.create("command", "Add Transparent TIFFs to Collection", "at the end of Tools");  
    }  
    tiffTransparency.onSelect = function () {   
    var fileList = Folder(app.document.presentationPath).getFiles("*.tif");  
    withTransparency = new Array();  
    for(var x in fileList){  
    var file = fileList[x];  
    file.open("r");  
    file.encoding = 'BINARY';  
    var dat = file.read();  
    file.close();  
    var result;  
    var pos = [];  
    var Text= [];  
    var rex = /Transparency/g;  // What to look for: ExifTool Tag 0x03ee AlphaChannelsNames = .Transparency
    while ((result = rex.exec(dat)) != null) {  
    pos.push(result.index+(result[0].length));  
    }  
    if(pos.length>0) withTransparency.push(new Thumbnail(fileList[x]));  
    dat=null;  
    }  
    if(withTransparency.length >0){  
    var foundFiles = app.createCollection("Transparent TIFFs");  
    app.addCollectionMember(foundFiles,withTransparency);  
        }  
    };

     

    Info on downloading/saving and installing scripts here:

     

    Prepression: Downloading and Installing Adobe Scripts

     

    P.S. If these methods are tool slow on 1000’s of images, then an ExifTool command could be run to dump the non-transparent files into a text file log, which should be pretty fast.

    3 replies

    Legend
    August 21, 2024

    I'm coming into this way late, but you can check for channels in an image. Three channels means it definitely can't have transparency.

    try{
    var sels = app.document.selections;
    if(ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
    var descMeta = sels[0].synchronousMetadata.read("http://ns.adobe.com/tiff/1.0/", "BitsPerSample");
    Window.alert(descMeta.length.toString());
    }
    catch(e){
    Window.alert(e + e.line);
    }
    Stephen Marsh
    Community Expert
    Stephen MarshCommunity ExpertCorrect answer
    Community Expert
    July 7, 2018

    OK, here is a hack to another Adobe Bridge script to add TIFF files WITH transparency to a collection… Yes, I know you wish to locate files without transparency, but at least this is a start… Stay with me here :]

     

    Once the collection is created, apply a unique metadata entry such as a label; star rating or keyword that is not used in your files to all of the transparent images in the collection.

     

    Now when you view the images outside of the collection back in their original locations, the label or rating will be visible. You can now easily sort and isolate the files with and without the label or rating etc using the filter panel, find command, smart collections etc.

     

    Job done!

     

    // https://forums.adobe.com/thread/1990912
    // https://forums.adobe.com/message/10481093
    #target bridge    
       if( BridgeTalk.appName == "bridge" ) {    
    tiffTransparency= MenuElement.create("command", "Add Transparent TIFFs to Collection", "at the end of Tools");  
    }  
    tiffTransparency.onSelect = function () {   
    var fileList = Folder(app.document.presentationPath).getFiles("*.tif");  
    withTransparency = new Array();  
    for(var x in fileList){  
    var file = fileList[x];  
    file.open("r");  
    file.encoding = 'BINARY';  
    var dat = file.read();  
    file.close();  
    var result;  
    var pos = [];  
    var Text= [];  
    var rex = /Transparency/g;  // What to look for: ExifTool Tag 0x03ee AlphaChannelsNames = .Transparency
    while ((result = rex.exec(dat)) != null) {  
    pos.push(result.index+(result[0].length));  
    }  
    if(pos.length>0) withTransparency.push(new Thumbnail(fileList[x]));  
    dat=null;  
    }  
    if(withTransparency.length >0){  
    var foundFiles = app.createCollection("Transparent TIFFs");  
    app.addCollectionMember(foundFiles,withTransparency);  
        }  
    };

     

    Info on downloading/saving and installing scripts here:

     

    Prepression: Downloading and Installing Adobe Scripts

     

    P.S. If these methods are tool slow on 1000’s of images, then an ExifTool command could be run to dump the non-transparent files into a text file log, which should be pretty fast.

    rob day
    Community Expert
    Community Expert
    July 7, 2018

    Rather than testing for transparency, which might not tell you if the transparency save option was checked, I wonder if a brute force save all would be better. Unless the files are quite large a SaveAs on all of the files should be pretty quick. Something like this that would get and save all of the files with a .tif extension in the chosen folder:

    var psdFolder = Folder.selectDialog("Select the folder containing TIFs", "");

    var myFiles = psdFolder.getFiles(/\.(tif)$/i);

    //enables transparency in the TIFF Save Options

    var so = new TiffSaveOptions();

    so.transparency = true;

    for (var a = 0; a < myFiles.length; a++){

        var d = open(myFiles);

        d.saveAs(new File(d.fullName), so);

        d.close();

    }; 

    Stephen Marsh
    Community Expert
    Community Expert
    July 7, 2018

    Thanks for contributing Rob! Yes, the brute force resave approach is a workable fallback, one does not even need a script to do this to batches of images.

    Rather than testing for transparency, which might not tell you if the transparency save option was checked

    It does tell you if the TIFF transparency option was used when saving, which is the reason that I suggested it. :]

    I performed many tests comparing layered files with/without the transparency checkbox used when saving vs. flat files etc. The transparency checkbox does not have to be used when saving a layered file. However if the transparency checkbox is used, then an entry is written to the file (this alpha channel transparency entry does not result in a physical alpha channel appearing in Photoshop when a file is opened though). This entry is not produced if layers are simply used, which is why the OP rejected my first solution as it was not targeted to the specific situation at hand.

    Stephen Marsh
    Community Expert
    Community Expert
    July 4, 2018

    You can use the following Adobe Bridge script:

    Find Layered TIFF Files

    Where three different methods are explored (Adobe Bridge; native Mac OS script; cross platform ExifTool).

    Info on installing Adobe scripts here:

    Prepression: Downloading and Installing Adobe Scripts

    P.S. Whether or not the transparency checkbox has been ticked, the above methods check for non-flattened, layered data.

    Mike_Gondek10189183
    Community Expert
    Community Expert
    July 6, 2018

    Thank you very much for your reply. All the tifs are layered so unfortunately this wont help.

    I need to find which ones are missing the transparency setting, so can flip that setting. Or a script that will turn that setting on.

    Stephen Marsh
    Community Expert
    Community Expert
    July 6, 2018

    OK, I should be able to come up with an ExifTool solution (perhaps an Adobe solution, but no promises). I’ll look into it and post back later.

    _______________

    The following ExifTool command line code will look for only TIFF files in the main top level folder or any sub-folders under this path. A new folder will be created in each directory/sub-directory titled “TIFF TRANS OFF”. The files without the transparency box checked will be moved the these named folders:

    exiftool -ext .tiff -ext .tif -if 'not defined $AlphaChannelsNames' -directory=%d'TIFF TRANS OFF' -r 'system path to top level folder'

    The following ExifTool command line code will look for only TIFF files in the main top level folder or any sub-folders under this path. A new folder will be created in each directory/sub-directory titled “TIFF TRANS ON”. The files with the transparency box checked will be moved the these named folders:

    exiftool -ext .tiff -ext .tif -if 'AlphaChannelsNames =~ /Transparency/' -directory=%d'TIFF TRANS ON' -r 'system path to top level folder'

    _______________

    The following ExifTool command line code will look for and overwrite only TIFF files in the main top level folder or any sub-folders under this path. The files without the transparency box checked will have an Adobe Bridge label of “Review” applied to them:

    exiftool -overwrite_original -ext .tiff -ext .tif -label='Review' -if 'not defined $AlphaChannelsNames' -r 'system path to top level folder'

    The following ExifTool command line code will look for and overwrite only TIFF files in the main top level folder or any sub-folders under this path. The files with the transparency box checked will have an Adobe Bridge label of “Approved” applied to them:

    exiftool -overwrite_original -ext .tiff -ext .tif -label='Approved' -if '$AlphaChannelsNames =~ /Transparency/' -r 'system path to top level folder'

    _______________

    NOTES:

    The first two examples move the original files.

    In the second set of examples the original files are overwritten. Rather than using an Adobe Bridge Label, a Bridge Star Rating could be used. Or perhaps a metadata entry such as a Keyword could be added. There are many possibilities.

    The commands found above are for the Mac OS, users of Windows would simply need to swap the straight single quote marks for straight double quotes.