~
Advanced Hosters -

MrBin
: 05.07.2007
: 76
# : 05, 2008 1:21 pm
, , .

.

:
photoshop>file>scripts>browse

, (photoshop>file>scripts>),
:
...\Adobe Photoshop CS2\Presets\Scripts\


: MrBin ( 05, 2008 1:44 pm), 2 ()
:
3- . .

MrBin
: 05.07.2007
: 76
# : 05, 2008 1:23 pm
CS2.
.

: SetCopyrite.jsx

:


:
#target photoshop

app.bringToFront();
app.displayDialogs = DialogModes.NO;
app.preferences.rulerUnits = Units.INCHES;
app.preferences.typeUnits = TypeUnits.POINTS;

var FolderInName = "C:/Temp/images_strojka/"; // -
var FolderOutName = "C:/Temp/images_strojka1/";//
var FileMask = "*.jpg"; // , - jpg
var options = new ExportOptionsSaveForWeb(); //
    options.format = SaveDocumentType.JPEG;
var textColor = new SolidColor; // RGB
    textColor.rgb.red = 0;
    textColor.rgb.green = 0;
    textColor.rgb.blue = 0;
var textsize = 24; //
var text = "www.MySite.ru"; //
var DeltaHorizontal = 2.25; // ,
var DeltaVertical = 0.25; // ,
var PositionHorizontal;
var PositionVertical;
var fillColor = new SolidColor(); //
    fillColor.rgb.red  = 255;
    fillColor.rgb.green = 255;
    fillColor.rgb.blue = 255;

// FileMask
var fold = new Folder(FolderInName);
if (!fold.exists){
   throw " :"+FolderInName;
}
var fold1 = new Folder(FolderOutName);
if (!fold1.exists){
   throw " :"+FolderOutName;
}

var ArrayFiles = fold.getFiles(FileMask);

//
for (ii = 0; ii < ArrayFiles.length; ii++) {
   var docRef = open(ArrayFiles[ii]);
   var targetFile = new File(FolderOutName +docRef.name);
   if(!targetFile.exists){   
        PositionHorizontal = docRef.width-DeltaHorizontal;
        PositionVertical = docRef.height-DeltaVertical;
    //
   var newTextLayer = docRef.artLayers.add();
   newTextLayer.kind = LayerKind.TEXT;
   newTextLayer.textItem.contents = text;
   newTextLayer.textItem.position = Array(PositionHorizontal, PositionVertical);
   newTextLayer.textItem.size = textsize;
   newTextLayer.textItem.color = textColor;
   //
        var ff = newTextLayer.bounds;
   docRef.activeLayer = docRef.layers[1];
   docRef.selection.select(Array (Array(ff[0]*docRef.resolution, ff[1]*docRef.resolution),
                        Array(ff[2]*docRef.resolution, ff[1]*docRef.resolution),
                   Array(ff[2]*docRef.resolution, ff[3]*docRef.resolution),
                   Array(ff[0]*docRef.resolution, ff[3]*docRef.resolution)),
                           SelectionType.REPLACE, 0, false);
   docRef.selection.fill(fillColor);
   //
      docRef.exportDocument(targetFile, ExportType.SAVEFORWEB, options);
   }
   docRef.close(SaveOptions.DONOTSAVECHANGES);   
}


//
options = null;
textColor = null;
newTextLayer = null;
fold = null;
targetFile = null;
docRef = null;
fold1 = null;
fillColor = null;

:
3- . .

MrBin
: 05.07.2007
: 76
# : 05, 2008 1:26 pm
vladsm, :
prizrak..com/129475.html?thread=481987#t481987

750500 (500750) .jpg (, 30002000), 128Kb.

:
#target photoshop
// in case we double clicked the file
app.bringToFront();
app.preferences.rulerUnits = Units.PIXELS;

var BaseH = 3000;
var BaseW = 2000;
var FinalH = 750;
var FinalW = 500;
var saveSize = 132000;

var FILE_TYPE = ".jpg";
var SEARCH_MASK = "*" + FILE_TYPE;

var X_NOINPUT = "noInput";
var X_BADDOC = "badDoc";
var X_RERROR = "resizeError";
var X_SERROR = "saveError";


main();

function main(){
   try{   
      var inputFolder = Folder.selectDialog("Select a folder to process");
      if (inputFolder == null){
         throw X_NOINPUT;
      }

      // get all files in the input folder
      var fileList = inputFolder.getFiles(SEARCH_MASK);

      for (var i = 0; i < fileList.length; i++) {
          // Only want to open non-hidden files (and no folders)
         if ((fileList[i] instanceof File) && (fileList[i].hidden == false)) {
            // Open the file in Photoshop
            var docRef = open(fileList[i]);
            if (docRef == null){
               throw X_BADDOC;
            }
         
            if(!mySharpResize(docRef)){
                throw X_RERROR;
            }
   
            if(!mySave(docRef)){
                throw X_SERROR;
            }
   
         // Close the Photoshop file
            docRef.close(SaveOptions.DONOTSAVECHANGES);            
         }
       }
      alert('Done!');
   }
   catch (e){
      alert(e);
   }

}

function mySharpResize(docRef){

   try{

      if(docRef.colorProfileName!='sRGB IEC61966-2.1'){
         docRef.convertProfile('sRGB IEC61966-2.1',Intent.RELATIVECOLORIMETRIC,true,true);
      }

      if(docRef.height>docRef.width){
      //vertical
         BH = BaseH;
         BW = BaseW;
         FH = FinalH;
         FW = FinalW;
      }else{
      //horizontal
         BH = BaseW;
         BW = BaseH;
         FH = FinalW;
         FW = FinalH;
      }

      docRef.changeMode(ChangeMode.LAB);
      docRef.activeChannels=Array(docRef.channels.getByName('Lightness'));

      if(docRef.width>BW){
         docRef.artLayers[0].applyUnSharpMask(20,2,10);
         docRef.resizeImage(BW,BH,docRef.resolution,ResampleMethod.BICUBIC);
      }

      BW = Number(BW/2);
      BH = Number(BH/2);
      if(docRef.width>BW){
         docRef.artLayers[0].applyUnSharpMask(120,0.8,2);
         docRef.resizeImage(BW,BH,docRef.resolution,ResampleMethod.BICUBIC);
      }

      if(docRef.width>FW){
         docRef.artLayers[0].applyUnSharpMask(120,0.4,1);
         docRef.resizeImage(FW,FH,docRef.resolution,ResampleMethod.BICUBIC);
      }

      docRef.artLayers[0].applyUnSharpMask(120,0.2,0);

      docRef.changeMode(ChangeMode.RGB);

      return true;

   }
   catch (e){
      alert("Error: " + e);
   }
}

function mySave(docRef){
    try{

      var options = new ExportOptionsSaveForWeb();
      options.format = SaveDocumentType.JPEG;

      var targetName = docRef.path + "/" + docRef.name.match( /[^.]+/) +"_b.jpg";   // Get root name, add required extension.
      var targetFile = new File(targetName);

      for (options.quality = 95; options.quality >0; options.quality = options.quality -10) {

         if (targetFile.exists){
            targetFile.remove();
         }

         docRef.exportDocument(targetFile, ExportType.SAVEFORWEB, options);

         var fileRef = new File( targetName );            // Necessary as "targetFile" length isn't refreshed.
         if (fileRef.length < saveSize ){
            break;            // All done if it's small enough already.
         }
        }
      return true;
   }
   catch (e){
      alert("Error: " + e);
   }
}

:
3- . .

MrBin
: 05.07.2007
: 76
# : 11, 2008 7:27 am
:
:
options.quality = 15;


:
:
var options = new ExportOptionsSaveForWeb(); //
    options.format = SaveDocumentType.JPEG;



, .
15 .
2 400-500( jpg) - 50-100 .
:
3- . .
    ~