script to compress tiffs and keep layers

mrjames

Suspended / Banned
Messages
1,240
Edit My Images
Yes
I have a large number of big (1gb+) tiffs, and a couple of 100 ones between 500-1000mb, overall about 200gb of archived files, which I would like to compress- hopefully regaining at least 60gb! I just converted my raw catalogue to DNG and regained 30gb.

from my testing I have deduced that the best file type for archiving edited, layered 16bit pictures is PSD, it has the lowest file size and the fastest save/close- tiff with zip compression and layer compression is similar file size but takes 3x the time to save

if you're interested in my test results:

for 8 bit:
tiff with LZW compression and layer compression gives the smallest files, much smaller than PSD

for 16 bit:
PSD gives smallest file compared to save/open time, Tiff with zip compression and layer compression is the best for file size but the space saving isn't worth the time cost. 16 bit tiffs with LZW compression are bigger than uncompressed tiffs!


In an ideal world there would be a script that you point at a folder (in this case the lr3 images folder), and it scanned for tiffs and opened the file, and just resaved with zip (for 16bit) or LZW (for 8bit) and applied layer compression- but every tool i've used can only create a 'converted' flattened tiff, and can't resave the same file

I would be interested in just converting to PSD but I think i'd lose the image in the catalogue and as a lot of them have extra cropping/editing I don't want to do that.

So any of got any tips? Or is this something I have to figure out how to do myself with applescript or photoshop scripts?
 
You could use something like this in Photoshop...

Code:
#target photoshop
app.bringToFront();
main();
function main(){
var inputFolder = Folder.selectDialog("Please select folder to process");
if(inputFolder == null) return;
var tifList = inputFolder.getFiles("*.tif");
for(var f in tifList){ 
app.open(tifList[f]);
var saveFile=new File(tifList[f].fsName);
if(app.activeDocument.bitsPerChannel == BitsPerChannelType.SIXTEEN) {
    SaveTIFF(saveFile,true);
    }else{
        SaveTIFF(saveFile);
        }
    app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); 
    }
};
function SaveTIFF(saveFile,sixteenBit){
tiffSaveOptions = new TiffSaveOptions(); 
tiffSaveOptions.embedColorProfile = true; 
tiffSaveOptions.alphaChannels = true; 
tiffSaveOptions.layers = true;
if(sixteenBit == undefined || sixteenBit == false){
tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW; 
}else{
    tiffSaveOptions.imageCompression = TIFFEncoding.TIFFZIP;
    }
activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE); 
};
 
thanks, i'll try it tonight and see how it goes
 
Back
Top