+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    save as procedure

    I want to make an Action do the following .....

    i have many jpg images with for example width 630 and height 430

    I want to cut it at half 315x215 and save its image seperatly if i had image test.jpg
    i want to have test1.jpg and test2.jpg

    Is this possible with action ... because i tried and i have problem with saving .. i tried batch too but i failed... Have anyone done it to tell me what to do???

    Thanks

  2. #2
    Junior Member
    Join Date
    Nov 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help

    Any help??

  3. #3
    The Script Master
    Join Date
    May 2009
    Location
    Bradford,UK
    Posts
    208
    Thanks
    0
    Thanked 39 Times in 34 Posts
    Your maths are not correct as you are asking for a quarter not half? 315x215=quarter
    I will assume you mean half and this will do a folder of files..
    Code:
    function main(){
    var inputFolder = Folder.selectDialog("Select a folder of documents to process");
    if(inputFolder == null) return;
    var fileList = inputFolder.getFiles(/\.(jpg|tif|psd)$/i); 
    var startRulerUnits = preferences.rulerUnits;
    preferences.rulerUnits = Units.PIXELS;
    
    for(var z in fileList){
    	open(fileList[z]);
    var doc = app.activeDocument;
    try{
    var leftFile = new File(decodeURI(activeDocument.fullName.fsName).slice(0,-4) + "1.jpg");  
    }catch(e){alert("You need to save this document first");return;}
    var rightFile = new File(decodeURI(activeDocument.fullName.fsName).slice(0,-4) + "2.jpg");  
    doc.flatten();
    var LB = app.activeDocument.activeLayer.bounds; 
    var savedState = doc.activeHistoryState;
    activeDocument.selection.select([[LB[0].value,LB[1].value], [(LB[2].value/2),LB[1].value], [(LB[2].value/2),LB[3].value], [LB[0].value, LB[3].value]], SelectionType.REPLACE, 0, false);
    executeAction( charIDToTypeID( "Crop" ), undefined, DialogModes.NO );
    SaveJPEG(leftFile,8);
    doc.activeHistoryState = savedState;
    activeDocument.selection.select([[LB[2].value/2,LB[1].value], [(LB[2].value),LB[1].value], [(LB[2].value),LB[3].value], [LB[2].value/2, LB[3].value]], SelectionType.REPLACE, 0, false);
    executeAction( charIDToTypeID( "Crop" ), undefined, DialogModes.NO );
    SaveJPEG(rightFile,8);
    app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    app.preferences.rulerUnits = startRulerUnits;
    	}
    }
    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);
    }

  4. #4
    Junior Member
    Join Date
    Nov 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks PAUL ...

    You must be very good in photoshop...

    How can i run this script you gave me ???

  5. #5
    The Script Master
    Join Date
    May 2009
    Location
    Bradford,UK
    Posts
    208
    Thanks
    0
    Thanked 39 Times in 34 Posts
    The best thing to do is to paste the code into ExtendScript Toolkit this can be found..

    PC: C:\Program Files\Adobe\Adobe Utilities
    MAC: <hard drive>/Applications/Utilities/Adobe Utilities
    Then save the script in..

    PC: C:\Program Files\Adobe\Adobe Photoshop CS#\Presets\Scripts
    MAC: <hard drive>/Applications/Adobe Photoshop CS#/ Presets/Scripts

    If Photoshop was open, close and restart Photoshop so that it can pick up the new script.
    You can then run the script by File - Scripts and choose the script.

    It will then prompt for the folder to process.

  6. #6
    Guru
    Join Date
    Jul 2009
    Location
    right in front of you
    Posts
    5,906
    Thanks
    23
    Thanked 147 Times in 144 Posts
    Paul MR
    you really seem to know your stuff, that coding business just blows me away Nice info

  7. #7
    Junior Member
    Join Date
    Nov 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Paul MR

    You are the BEST

    Thanks

  8. #8
    Junior Member
    Join Date
    Nov 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can i make one more newbie question ...

    1. I saw the script and i see the jpg quality ..
    How can i tell to the script that i want quality 70 ?? I dont know jsx at all ...

    2. Can i tell the script to create and save to an other folder ?

    Thanks
    Last edited by webbuilders; 11-25-2009 at 10:55 AM.

  9. #9
    The Script Master
    Join Date
    May 2009
    Location
    Bradford,UK
    Posts
    208
    Thanks
    0
    Thanked 39 Times in 34 Posts
    I have now modified it so that it asks for an output folder, also change the output to Save For Web with a quality of 70.
    Code:
    #target photoshop
    function main(){
    //Amend quality to suit
    var Quality = 70;
    var inputFolder = Folder.selectDialog("Select a folder of documents to process");
    var outputFolder = Folder.selectDialog("Select Destination Folder");
    if(inputFolder == null) return;
    if(outputFolder == null) return;
    var fileList = inputFolder.getFiles(/\.(jpg|tif|psd)$/i); 
    var startRulerUnits = preferences.rulerUnits;
    preferences.rulerUnits = Units.PIXELS;
    
    for(var z in fileList){
    	open(fileList[z]);
    var doc = app.activeDocument;
    var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
    try{
    var leftFile = new File(outputFolder +"/"+Name + "1.jpg");  
    }catch(e){alert("You need to save this document first");return;}
    var rightFile = new File(outputFolder +"/"+Name + "2.jpg");  
    doc.flatten();
    var LB=[];
    LB = app.activeDocument.activeLayer.bounds; 
    var savedState = doc.activeHistoryState;
    activeDocument.selection.select([[LB[0].value,LB[1].value], [(LB[2].value/2),LB[1].value], [(LB[2].value/2),LB[3].value], [LB[0].value, LB[3].value]], SelectionType.REPLACE, 0, false);
    executeAction( charIDToTypeID( "Crop" ), undefined, DialogModes.NO );
    SaveForWeb(leftFile,Quality);
    doc.activeHistoryState = savedState;
    activeDocument.selection.select([[LB[2].value/2,LB[1].value], [(LB[2].value),LB[1].value], [(LB[2].value),LB[3].value], [LB[2].value/2, LB[3].value]], SelectionType.REPLACE, 0, false);
    executeAction( charIDToTypeID( "Crop" ), undefined, DialogModes.NO );
    SaveForWeb(rightFile,Quality);
    app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    	}
    app.preferences.rulerUnits = startRulerUnits;
    }
    main();
    
    function SaveForWeb(saveFile,jpegQuality) {
    var sfwOptions = new ExportOptionsSaveForWeb(); 
       sfwOptions.format = SaveDocumentType.JPEG; 
       sfwOptions.includeProfile = false; 
       sfwOptions.interlaced = 0; 
       sfwOptions.optimized = true; 
       sfwOptions.quality = jpegQuality; //0-100 
    activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);
    }

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Powered by vBulletin® Version 4.1.9
Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.
Content Relevant URLs by vBSEO 3.6.0
Copyright 2011 Photoshop Gurus Forum. All rights reserved.
All times are GMT -5. The time now is 12:27 PM.
vBulletin Skins