2015-06-11 77 views
0

我需要拍攝大約500張1024x768分辨率圖像的文件夾,並將它們一次合併爲一張3072x768的全景圖。 (不是Photoshop的photomerge)Photoshop腳本:並排合併3幅圖像

我絕不是程序員;只是偶然發現了這個網站,每個人似乎都很有幫助。我傾向於在Photoshop中使用Java腳本可能是我最好的選擇。

我將源文件重命名爲:

Image_SD_1a

Image_SD_1b

Image_SD_1c

Image_SD_2a

...等等...

建立一個三個圖像,它需要保存我n要另一個文件夾爲JPG,如:

Image_001

Image_002

...等等...但我可以做一個批量重命名的過程之後。

我搜索並找到了這兩個接近的腳本,但我不夠聰明,無法添加「第三」圖像步驟或更改文件名結構。

How to batch combine two unique series of images into a single side-by-side image in Photoshop?

Merging files together (side by side) in folder Photoshop scripts

任何幫助是非常感謝!

+0

ImageMagick可能是你最好的選擇。 [看到這個問題](http://stackoverflow.com/questions/12076293/)。我認爲'convert + append Image_SD_1 * Image_001.jpg'將是將Image_SD_1 [abc] .jpg合併到Image_001.jpg的合適語法。你可以使用'for/L'循環多次執行這個命令。 – rojo

回答

0

這個腳本會做你想做的。 它適用於這些原則:

  • 所有的圖像(Image_SD_1a.jpg,Image_SD_1b.jpg,Image_SD_1b.jpg)是在同一目錄下。
  • 圖片爲jpegs(將保存爲Image_SD_1abc.jpg)
  • 圖片將被保存在與其他圖片相同的文件夾中。
  • 打開圖片A AND THEN運行腳本。

這不是完美的,它可以改善,做得更好,但是很累,而且我的咖啡用完了。腳本如下:

//pref pixels 
app.preferences.rulerUnits = Units.PIXELS; 


// call the source document 
var srcDoc = app.activeDocument; 
var ext = getFileExtension(srcDoc); 
var docPath = srcDoc.path; 

// get original width and height 
var imageW = srcDoc.width.value; 
var imageH = srcDoc.height.value; 

// name the mother 
var docName = srcDoc.name; 

// get names for images B & C 
var imageStub = getImageName(docName); 
var imageB = docPath + "/" + imageStub + "b" + ext; 
var imageC = docPath + "/" + imageStub + "c" + ext; 

// load image B % copy it 
openThisFile(imageB); 
activeDocument.selection.selectAll(); 
activeDocument.selection.copy(); 
activeDocument.selection.deselect(); 
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); 


// return to image A 
app.activeDocument = srcDoc; 

// paste it 
activeDocument.paste(); 
translateLayer(imageW, 0); 

// do the same for C 
// load image C % copy it 
openThisFile(imageC); 
activeDocument.selection.selectAll(); 
activeDocument.selection.copy(); 
activeDocument.selection.deselect(); 
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); 

// return to image A 
app.activeDocument = srcDoc; 

// paste it 
activeDocument.paste(); 
translateLayer(imageW *2, 0); 


// resize canvas 
srcDoc.resizeCanvas(imageW *3, imageH, AnchorPosition.MIDDLELEFT); 

// flatten it 
srcDoc.flatten(); 

// save it out 
var tempName = imageStub + "abc"; 
saveMe(docPath, tempName, 12); 

// close the new doc 
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); 

function getImageName (astring) 
{ 
    // Image_SD_1a.jpg 
    astring += ""; 
    //re move extension -1 
    var temp = astring.substring(0, astring.lastIndexOf(".")); 
    return temp.substring(0, temp.length-1); 
} 

function getFileExtension (astring) 
{ 
    astring += ""; 
    var x = astring.substring(astring.lastIndexOf("."), astring.length-1); 
    //alert(x); 
    return x; 
} 

// function OPENTHISFILE (masterFileNameAndPath) 
// -------------------------------------------------------- 
function openThisFile(masterFileNameAndPath) 
{ 
    var fileRef = new File(masterFileNameAndPath) 
    if (fileRef.exists) 
    //open that doc 
    { 
     app.open(fileRef); 
    } 
    else 
    { 
     alert("error opening " + masterFileNameAndPath) 
    } 
} 

function saveMe(fPath, fname, myJpgQuality) 
{ 
    //vegetables 
    if (!myJpgQuality) myJpgQuality = 12; 

    // Set filePath and fileName to source path 
    filePath = fPath + "/" + fname + ".jpg"; 

    var jpgFile = new File(filePath); 
    jpgSaveOptions = new JPEGSaveOptions(); 
    jpgSaveOptions.formatOptions = FormatOptions.OPTIMIZEDBASELINE; 
    jpgSaveOptions.embedColorProfile = true; 
    jpgSaveOptions.matte = MatteType.NONE; 
    jpgSaveOptions.quality = myJpgQuality; 

    activeDocument.saveAs(jpgFile, jpgSaveOptions, true, Extension.LOWERCASE); 
} 

function translateLayer(dx,dy) 
{ 
    // ======================================================= 
    var id2014 = charIDToTypeID("Trnf"); 
    var desc416 = new ActionDescriptor(); 
    var id2015 = charIDToTypeID("null"); 
    var ref287 = new ActionReference(); 
    var id2016 = charIDToTypeID("Lyr "); 
    var id2017 = charIDToTypeID("Ordn"); 
    var id2018 = charIDToTypeID("Trgt"); 
    ref287.putEnumerated(id2016, id2017, id2018); 
    desc416.putReference(id2015, ref287); 
    var id2019 = charIDToTypeID("FTcs"); 
    var id2020 = charIDToTypeID("QCSt"); 
    var id2021 = charIDToTypeID("Qcsa"); 
    desc416.putEnumerated(id2019, id2020, id2021); 
    var id2022 = charIDToTypeID("Ofst"); 
    var desc417 = new ActionDescriptor(); 
    var id2023 = charIDToTypeID("Hrzn"); 
    var id2024 = charIDToTypeID("#Pxl"); 
    desc417.putUnitDouble(id2023, id2024, dx); 
    var id2025 = charIDToTypeID("Vrtc"); 
    var id2026 = charIDToTypeID("#Pxl"); 
    desc417.putUnitDouble(id2025, id2026, dy); 
    var id2027 = charIDToTypeID("Ofst"); 
    desc416.putObject(id2022, id2027, desc417); 
    executeAction(id2014, desc416, DialogModes.NO); 
}