Skip to main content
Participant
July 9, 2023
解決済み

a Script or Batch to Vertically Combine Multiple Images

  • July 9, 2023
  • 返信数 3.
  • 2294 ビュー

Hello,

 

I'm looking for a way to create a batch or script that can vertically combine multiple images from within a single folder. Ideally, the vertically stacked images would be directly connected without any space in between, and they would remain as separate layers rather than merging.

Since all the images within the folder are of the same size, there would be no need for a feature to adjust the size.

 

While I've come across posts discussing how to combine images horizontally via batch, I haven't been able to find any information on doing the same vertically. Hence, I'm reaching out here for assistance.

 

Thank you in advance!

このトピックへの返信は締め切られました。

返信数 3

Stephen Marsh
Community Expert
Community Expert
July 9, 2023

@hamigua – I made a quick edit to the script that I offered in the topic that you linked to:

 

/*
Combine Images Vertically.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-merge-3-images-togehter-stacked-in-a-batch/td-p/13922876
Based on:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-combine-images-horizontally-via-batch/td-p/12716190
Stephen Marsh, v1.0 - 9th July 2023
*/

$.evalFile(File(app.path + '/Presets/Scripts/Load Files into Stack.jsx'));
var newHeight = app.activeDocument.layers.length * 100;
canvasSize(newHeight);
align2SelectAll('AdBt');
app.runMenuItem(stringIDToTypeID('selectAllLayers'));
distributeVertically();


// Functions

function distributeVertically() {
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};
	var descriptor = new ActionDescriptor();
	var reference = new ActionReference();
	reference.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "targetEnum" ));
	descriptor.putReference( s2t( "null" ), reference );
	descriptor.putEnumerated( s2t( "using" ), s2t( "alignDistributeSelector" ), s2t( "ADSDistV" ));
	executeAction( s2t( "distort" ), descriptor, DialogModes.NO );
}

function canvasSize(height) {
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};

	var descriptor = new ActionDescriptor();

	descriptor.putUnitDouble( s2t( "height" ), s2t( "percentUnit" ), height );
	descriptor.putEnumerated( s2t( "horizontal" ), s2t( "verticalLocation" ), s2t( "top" ));
	executeAction( s2t( "canvasSize" ), descriptor, DialogModes.NO );
}

function align2SelectAll(method) {

   app.activeDocument.selection.selectAll();

   var desc = new ActionDescriptor();
   var ref = new ActionReference();
   ref.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
   desc.putReference(charIDToTypeID("null"), ref);
   desc.putEnumerated(charIDToTypeID("Usng"), charIDToTypeID("ADSt"), charIDToTypeID(method));
   try {
      executeAction(charIDToTypeID("Algn"), desc, DialogModes.NO);
   } catch (e) { }

   app.activeDocument.selection.deselect();

}

 

 

The script presumes that the height of all layers is the same.

hamigua作成者
Participant
July 9, 2023
Stephen Marsh
Community Expert
Community Expert
July 9, 2023
quote

https://community.adobe.com/t5/photoshop-ecosystem-discussions/script-help-export-merge-many-picture-into-one/td-p/13016395

This one works!! Thank you so much for all your help ❤


By @hamigua

 

Great! I'd be interested if you could answer the questions in my previous posts and try the script code that I also posted.

Stephen Marsh
Community Expert
Community Expert
July 9, 2023

@hamigua 

 

How many images in each set to combine into a single image?

 

If you found solutions for horizontal stacks, then they should be able to be easily modified into vertical.

 

The following current topic stacks sets of 3 images into a vertical strip:

 

https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-merge-3-images-togehter-stacked-in-a-batch/td-p/13922876

 

hamigua作成者
Participant
July 9, 2023

The number of images in the folder isn't always consistent. Sometimes there may be 5 images, other times 25, but it won't exceed 50.

I'm at the beginner's stage in scripting, and I tried to modify the file into vertical alignment but it didn't go well.

Stephen Marsh
Community Expert
Community Expert
July 9, 2023

Ah, so the set quantity is based on the source folder file count, not the source folder count divided by a specific set quantity...

 

If you provide a link to the code for the horizontal stack it can be used as a starting point for the vertical. No need to reinvent the wheel here.