2017-03-17 3 views
-1

J'ai un fichier TIFF. Je veux le découper automatiquement (en spécifiant le nombre de tranches en horizontal et vertical) et les enregistrer dans des fichiers TIFF (je ne veux pas changer le format en png ou ...)Trancher automatiquement un grand fichier TIFF avec Photoshop et enregistrer des tranches dans des fichiers TIFF?

Je sais que vous pouvez choisir le outil de tranche >> clic droit >> Diviser la tranche >> Enregistrer pour le Web

mais la fonction « Enregistrer pour le Web » ne propose pas l'enregistrement au format TIFF et aussi je ne pense pas qu'il peut travailler pour un grand fichier.

Tout ce qui peut aider (script, plug-in) est la bienvenue

+0

Vous pouvez convertir une tranche en couches (puis enregistrer en tant que tiff) [voir la question SU] (https://superuser.com/questions/425811/is-it-possible-in-photoshop-to-convert-slices-into -photoshop-couches) –

+0

@MrMysteryGuest Merci, je vais essayer. –

+0

@MrMysteryGuest Veuillez voir la réponse ci-dessous. Je dépendais de la manière directe d'enregistrer dans les fichiers Tiff au lieu de cela. –

Répondre

0

Selon les ressources en ligne et avec un certain codage, le script ci-dessous est capable de découper automatiquement un grand TIFF en fichiers Tiff plus petits:

#target photoshop 
function main(){ 
if(!documents.length) return; 
var dlg= 
"dialog{text:'Script Interface',bounds:[100,100,380,290],"+ 
"panel0:Panel{bounds:[10,10,270,180] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+ 
"title:StaticText{bounds:[60,10,220,40] , text:'File Chop' ,properties:{scrolling:undefined,multiline:undefined}},"+ 
"panel1:Panel{bounds:[10,40,250,130] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+ 
"statictext1:StaticText{bounds:[10,10,111,30] , text:'Accross' ,properties:{scrolling:undefined,multiline:undefined}},"+ 
"statictext2:StaticText{bounds:[140,10,230,27] , text:'Down' ,properties:{scrolling:undefined,multiline:undefined}},"+ 
"across:DropDownList{bounds:[10,30,100,50]},"+ 
"down:DropDownList{bounds:[140,30,230,50]},"+ 
"saveFiles:Checkbox{bounds:[10,60,230,80] , text:'Save and Close new files?'}},"+ 
"button0:Button{bounds:[10,140,110,160] , text:'Ok' },"+ 
"button1:Button{bounds:[150,140,250,160] , text:'Cancel' }}};" 
var win = new Window(dlg,'File Chop'); 
if(version.substr(0,version.indexOf('.'))>9){ 
win.panel0.title.graphics.font = ScriptUI.newFont("Georgia","BOLD",20); 
g = win.graphics; 
var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [1.00, 1.00, 1.00, 1]); 
g.backgroundColor = myBrush; 
var myPen =g.newPen (g.PenType.SOLID_COLOR, [1.00, 0.00, 0.00, 1],lineWidth=1); 
} 
win.center(); 
    for(var i=1;i<31;i++){ 
    win.panel0.panel1.across.add ('item', i);  
    win.panel0.panel1.down.add ('item', i);  
    } 
win.panel0.panel1.across.selection=0; 
win.panel0.panel1.down.selection=0; 
var done = false; 
    while (!done) { 
     var x = win.show(); 
     if (x == 0 || x == 2) { 
     win.canceled = true; 
     done = true; 
     } else if (x == 1) { 
     done = true; 
     { 
if(!documents.length)return; 
var startRulerUnits = preferences.rulerUnits; 
preferences.rulerUnits = Units.PIXELS; 
doc = app.activeDocument; 
app.displayDialogs = DialogModes.NO; 
doc.flatten(); 
var tilesAcross = parseInt(win.panel0.panel1.across.selection.index)+1; 
var tilesDown =parseInt(win.panel0.panel1.down.selection.index)+1; 
var tileWidth = parseInt(doc.width/tilesAcross); 
var tileHeight = parseInt(doc.height/tilesDown); 
var SaveFiles = win.panel0.panel1.saveFiles.value; 
ProcessFiles(tilesDown,tilesAcross,tileWidth,tileHeight,SaveFiles); 
app.preferences.rulerUnits = startRulerUnits;  
     } 
    } 
    } 
} 
main(); 
function ProcessFiles(Down,Across,offsetX,offsetY,SaveFiles){ 
try{ 
var newName = activeDocument.name.match(/(.*)\.[^\.]+$/)[1]; 
}catch(e){var newName="UntitledChop"} 
var Path=''; 
try{ 
Path = activeDocument.path; 
}catch(e){Path = "~/Desktop";} 
if(SaveFiles){ 
Path = Folder(decodeURI(Path) +"/FileChop"); 
if(!Path.exists) Path.create(); 
    } 
TLX = 0; TLY = 0; TRX = offsetX; TRY = 0; 
BRX = offsetX; BRY = offsetY; BLX = 0; BLY = offsetY; 
for(var a = 0; a < Down; a++){ 
    for(var i = 0;i <Across; i++){ 
      var NewFileName = newName +"#"+a+"-"+i; 
    app.activeDocument.duplicate (NewFileName, true); 
    activeDocument.selection.select([[TLX,TLY],[TRX,TRY],[BRX,BRY],[BLX,BLY]], SelectionType.REPLACE, 0, false); 
    executeAction(charIDToTypeID("Crop"), undefined, DialogModes.NO); 
    app.activeDocument.selection.deselect(); 
if(SaveFiles){ 
var saveFile = File(decodeURI(Path+"/"+NewFileName+".tiff")); 
SaveTIFF(saveFile); 
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); 
} 
    activeDocument = documents[0]; 
TLX = offsetX * (i+1) ; TRX = TLX + offsetX; BRX = TRX; BLX = TLX; 
    } 
TLX = 0; TLY = offsetY * (a +1); TRX = offsetX; TRY = offsetY * (a +1); 
BRX = offsetX; BRY = TRY + offsetY; BLX = 0; BLY = (offsetY * (a +1)+offsetY); 

} 
if(SaveFiles){ 
Path.execute() 
    } 
} 
function SaveTIFF(saveFile){ 
tiffSaveOptions = new TiffSaveOptions(); 
tiffSaveOptions.embedColorProfile = true; 
tiffSaveOptions.alphaChannels = true; 
tiffSaveOptions.layers = true; 
tiffSaveOptions.imageCompression = TIFFEncoding.NONE; 
activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE); 
}