🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.photoshop.scripting
5 messages
5 total messages Started by Phil_Gwynne Fri, 03 Apr 2009 15:16
Action that resizes images by title that end in "_1" only
#79
Author: Phil_Gwynne
Date: Fri, 03 Apr 2009 15:16
12 lines
1425 bytes
Hi everyone,

I've been looking all over the place for any scripts / actions to suit my needs but I can't seem to find any anywhere and my scripting knowledge is quite limited!

Basically, I'm in need of an action that is like the batch processor in photoshop. Except instead of resizing all of the images within a specified folder, it will only resize images that end in "_1" after their respective titles. For example the script would ignore "93725.tif" or "93725_2.tif", but it would resize "93725_1.tif".

I'm looking to resize my original TIF files ending in "_1" to 175px x 175px, and to save them into a different folder as a JPEG, but keeping the original TIF files at the same time so I have a backup.

If anyone could help with the matter I'd be very grateful!

Thanks,
Phil
Re: Action that resizes images by title that end in "_1" only
#85
Author: Mark_Larsen
Date: Fri, 03 Apr 2009 18:26
1 lines
813 bytes
Phil, you are going to require a scripted solution to be able to do this. What platform are you on you can use 3 languages with Photoshop. What is your scripting knowledge in?
Re: Action that resizes images by title that end in "_1" only
#86
Author: Paul_R
Date: Fri, 03 Apr 2009 18:46
185 lines
4876 bytes
This should be close...


 
function main(){ 

var dlg= 

"dialog{text:'Script Interface',bounds:[100,100,500,410],"+ 

"panel0:Panel{bounds:[10,10,390,300] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+ 

"title:StaticText{bounds:[70,10,320,40] , text:'Resize Tif, Convert to JPG' ,properties:{scrolling:undefined,multiline:undefined}},"+ 

"panel1:Panel{bounds:[10,50,370,120] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+ 

"statictext1:StaticText{bounds:[10,10,130,27] , text:'Source Folder' ,properties:{scrolling:undefined,multiline:undefined}},"+ 

"source:EditText{bounds:[10,40,350,60] , text:'' ,properties:{multiline:false,noecho:false,readonly:false}},"+ 

"browse1:Button{bounds:[240,10,340,30] , text:'Browse' }},"+ 

"panel2:Panel{bounds:[10,130,370,200] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+ 

"statictext2:StaticText{bounds:[10,10,111,27] , text:'Output Folder' ,properties:{scrolling:undefined,multiline:undefined}},"+ 

"browse2:Button{bounds:[240,10,340,30] , text:'Browse' },"+ 

"output:EditText{bounds:[10,40,350,60] , text:'' ,properties:{multiline:false,noecho:false,readonly:false}}},"+ 

"panel3:Panel{bounds:[10,210,370,250] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+ 

"statictext3:StaticText{bounds:[10,10,180,30] , text:'Output JPG Quality' ,properties:{scrolling:undefined,multiline:undefined}},"+ 

"quality:DropDownList{bounds:[250,10,336,30]}},"+ 

"button2:Button{bounds:[10,260,180,281] , text:'Ok' },"+ 

"button3:Button{bounds:[200,260,370,281] , text:'Cancel' }}};" 

var win = new Window(dlg,'Resize TIFs'); 

win.center(); 

if(version.substr(0,version.indexOf('.'))>9){ 

win.panel0.title.graphics.font = ScriptUI.newFont("Times","BOLDITALIC",16); 

} 

win.panel0.panel1.source.enabled=false; 

win.panel0.panel2.output.enabled=false; 

 

win.panel0.panel1.browse1.onClick = function() { 

 inputFolder = Folder.selectDialog("Please select the folder with Files to process");    

   if(inputFolder !=null){ 

      win.panel0.panel1.source.text =  decodeURI(inputFolder.fsName);  

      } 

} 

win.panel0.panel2.browse2.onClick = function() { 

 outputFolder = Folder.selectDialog("Please select the output folder");    

   if(outputFolder !=null){ 

      win.panel0.panel2.output.text =  decodeURI(outputFolder.fsName);  

      } 

} 

for(var a = 1;a <13;a++){ 

 win.panel0.panel3.quality.add('item',a); 

 } 

  win.panel0.panel3.quality.selection=7; 

var done = false;  

    while (!done) {  

      var x = win.show();  

      if (x == 0 || x == 2) { 

        win.canceled = true; 

        //Cancelled 

        done = true;  

      } else if (x == 1) {  

        done = true;  

       var result = valiDate(); 

        if(result != true) { 

           alert(result); 

           return; 

        }else 

        { 

      ProcessFolder(); 

        } 

      }  

   }  

 

function valiDate(){ 

if(win.panel0.panel1.source.text == '') return 'No Source Folder selected'; 

if(win.panel0.panel2.output.text == '') return 'No Output Folder selected'; 

return true; 

} 

function ProcessFolder(){ 

var fileList = inputFolder.getFiles("*.tif"); 

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

   var file = fileList[a]; 

var fileName = fileList[a].name.match(/(.*)\.[^\.]+$/)[1]; 

if(fileName.match(/_1$/)){ 

   open(file); 

activeDocument.resizeImage( 175, undefined, undefined, ResampleMethod.BICUBICSHARPER ); 

var saveFile= new File(outputFolder+"/"+fileName+".jpg"); 

SaveJPEG(saveFile, parseInt(win.panel0.panel3.quality.selection.index+1)); 

app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);  

   } 

} 

} 

} 

main(); 

function SaveJPEG(saveFile, jpegQuality){ 

jpgSaveOptions = new JPEGSaveOptions(); 

jpgSaveOptions.embedColorProfile = true; 

jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE; 

jpgSaveOptions.matte = MatteType.NONE; 

jpgSaveOptions.quality = jpegQuality; //1-12 

activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE); 

}
Re: Action that resizes images by title that end in "_1" only
#87
Author: Mark_Larsen
Date: Fri, 03 Apr 2009 19:17
1 lines
942 bytes
Paul, I will take a good look at your code as a learning exercise. Im wanting to get into JavaScript some valuable stuff in that Im sure. I can sometimes make more from posts here than I can with the ref guide. So thanks from me too.
Re: Action that resizes images by title that end in "_1" only
#88
Author: Paul_R
Date: Fri, 03 Apr 2009 19:27
2 lines
944 bytes
I am still learning from the great moderators at PS-Scripts.com Mark, there are loads of examples and it's a wonderful reference site.
One day I might even venture into the world of AppleScript as I have two Macs but only use them as a last resort as I was brought up on PCs from when they had 4.3Mhz processors, no HD and a 360/720k floppy.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads