यह स्क्रिप्ट वह वही करेगा जो आप चाहते हैं। सभी फ़ाइलों को निर्देशिका में रखें और फिर स्वचालित बैच -> स्क्रिप्ट का उपयोग करके स्क्रिप्ट चलाएं। इसे फ़ाइल-नाम में बिना अंडरस्कोर के एक छवि मिलेगी और फिर इसे युग्मित नाम फ़ाइल ("_m" के साथ) खोलें, उन्हें एक तरफ रख दें और फ़ाइल नाम पर जोड़े गए _done के साथ इसे सेव करें।
// pref पिक्सेल app.preferences.rulerUnits = Units.PIXELS;
var srcDoc = app.activeDocument;
// call the current document
var srcDoc = app.activeDocument;
// set original width and height
var imageW = srcDoc.width.value;
var imageH = srcDoc.height.value;
// get the info out of the source doc
var fileName = srcDoc.name;
var docName = fileName.substring(0,fileName.length -4);
var filePath = srcDoc.path.toString();
var fileExt = fileName.substring(fileName.length -4, fileName.length);
var nameCheck = fileName.substring(0,fileName.indexOf("_"));
if (nameCheck <1)
{
// no underscore so we need to open it's namesake
// alert(nameCheck)
var filePair = filePath + "/" + docName + "_m" + fileExt;
openThisFile(filePair)
activeDocument.selection.selectAll()
activeDocument.selection.copy();
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
app.activeDocument = srcDoc;
activeDocument.resizeCanvas(imageW *2, imageH, AnchorPosition.MIDDLELEFT);
selectRect(0, imageW, imageW*2, imageH)
activeDocument.paste()
activeDocument.flatten();
var newName = filePath + "/" + docName + "_done" + fileExt
saveMe(newName)
}
else
{
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
function openThisFile(masterFileNameAndPath)
{
var fileRef = new File(masterFileNameAndPath)
if (fileRef.exists)
//open that doc
{
app.open(fileRef);
}
else
{
alert("error opening " + masterFileNameAndPath)
}
}
function selectRect(top, left, right, bottom)
{
srcDoc.selection.deselect()
// =======================================================
var id1 = charIDToTypeID("setd");
var desc1 = new ActionDescriptor();
var id2 = charIDToTypeID("null");
var ref1 = new ActionReference();
var id3 = charIDToTypeID("Chnl");
var id4 = charIDToTypeID("fsel");
ref1.putProperty(id3, id4);
desc1.putReference(id2, ref1);
var id5 = charIDToTypeID("T ");
var desc2 = new ActionDescriptor();
var id6 = charIDToTypeID("Top ");
var id7 = charIDToTypeID("#Pxl");
desc2.putUnitDouble(id6, id7, top);
var id8 = charIDToTypeID("Left");
var id9 = charIDToTypeID("#Pxl");
desc2.putUnitDouble(id8, id9, left);
var id10 = charIDToTypeID("Btom");
var id11 = charIDToTypeID("#Pxl");
desc2.putUnitDouble(id10, id11, bottom);
var id12 = charIDToTypeID("Rght");
var id13 = charIDToTypeID("#Pxl");
desc2.putUnitDouble(id12, id13, right);
var id16 = charIDToTypeID("Rctn");
desc1.putObject(id5, id16, desc2);
executeAction(id1, desc1, DialogModes.NO);
}
function saveMe(fPath)
{
// save out the image
var pngFile = new File(fPath);
pngSaveOptions = new PNGSaveOptions();
pngSaveOptions.embedColorProfile = true;
pngSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
pngSaveOptions.matte = MatteType.NONE; pngSaveOptions.quality = 1;
activeDocument.saveAs(pngFile, pngSaveOptions, false, Extension.LOWERCASE);
// close that saved png
app.activeDocument.close()
}
स्रोत
2012-11-23 17:00:00
स्क्रिप्ट के लिए धन्यवाद। यह सही काम करता है। मैं बस बैच नहीं ढूंढ सकता -> स्क्रिप्ट कमांड यह केवल फ़ोटोशॉप के विस्तारित संस्करण में है? – adam
सबसे पहले स्क्रिप्ट को एक क्रिया के रूप में रिकॉर्ड करें। एक्शन -> नई एक्शन (इसे एक नाम दें), रिकॉर्ड करें और फिर रिकॉर्डिंग बंद करें - यह अक्सर महत्वपूर्ण है। और फिर बैच फ़ाइल से स्क्रिप्ट को कॉल करें। मुझे CS5 के बारे में निश्चित नहीं है - लेकिन निश्चित रूप से CS2 के तहत आप इसे फ़ाइल -> स्वचालित -> बैच के अंतर्गत पाएंगे, फिर उस फ़ोल्डर को चुनें जिसमें वह है। इसे चलाने के लिए ठीक दबाएं। –
अब यह काम बेकार ढंग से धन्यवाद है। – adam