0

我需要将两个系列的图像(都具有相同的分辨率,保存为 JPG 文件)合并到一个 JPG 文件中,并且图像彼此并排。我曾尝试使用 Photoshop CS6 操作来执行此操作,但无济于事……我在互联网上搜索了可能的解决方案,但事实证明,编写脚本来执行此类功能需要编程知识。我想在以下方面获得任何帮助:

我的文件名是这样的:

系列一:bone00001.jpg、bone00002.jpg ... bone00060.jpg 系列二:st00001.jpg、st00002.jpg ... st00060.jpg

我希望它们并排组合,以便“骨骼”系列在左侧,“st”系列在右侧,最终系列导出为 done00001.jpg ... done00060.jpg

任何人都可以帮助我处理这个 Photoshop 脚本吗?

4

1 回答 1

1

Adam D 是对的 - 你最好在Adob​​e 论坛上提问但幸运的是,您的请求与不久前提出的问题非常相似。剧本很粗糙;但它会做你想做的事:图像需要相同大小。如果骨骼图像比扫描图像小,它看起来会很乱并且无法工作。

将其保存为 .jsx 文件。它可以在 PS 中从文件 > 脚本菜单访问。

加载其中一个骨骼图像,运行脚本 - 然后它将找到匹配的扫描图像并将它们并排放置并将它们保存为 bone_XXXX_done.jpg(其中 XXXX 是数字)

    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("bone"));

if (nameCheck <1)
{
   var fileNum = fileName.substring(4,fileName.length -4);
   // no underscore so we need to open it's namesake
   // alert(nameCheck)
   var filePair = filePath + "/" + "st" + fileNum + 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 as jpeg
var jpgFile = new File(fPath);
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.formatOptions = FormatOptions.OPTIMIZEDBASELINE;
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = 12;

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

// close that saved jpg
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
于 2013-01-17T11:27:33.893 回答