Skip to content

Instantly share code, notes, and snippets.

@pigeonhill
Last active January 14, 2021 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pigeonhill/309a7be818d4d523d50684e0fecd2d6c to your computer and use it in GitHub Desktop.
Save pigeonhill/309a7be818d4d523d50684e0fecd2d6c to your computer and use it in GitHub Desktop.
/*
Image Averaging Photoshop Script
Orginal script written by Neil Farquharson | www.verdantvista.com
Augmented by Garry George | www.photography.grayheron.net
Version 1.0.0
Date April 2018
Installation
------------------------
Copy into your scripts folder in Photoshop
Usage
------------------------
Load your frames to be image averaged into a single photoshop document. E.G. if you have 5 frames, they should be stacked in one document as 5 seperate layers.
At the prompt enter a number typically between 2 and 10: note the script does NOT test the input. Select NO to the merge request in this first pass.
Leave the default 100 for normal use, ie a single block, which you can merge if you wish.
After the first pass you will have clearly deleneated blocks of variable opacity: merge each block manually by selecting them.
These merged blocks can then be reprocessed with the script to a single layer, ie YES to merge request.
*/
if (documents.length == 0)
{
alert("There are no documents open.");
}
else
{
var myDoc = activeDocument;
var layerRef = myDoc.activeLayer;
var myLayerCount = myDoc.layers.length-1;
var blockNum = 1;
if (myDoc.layers.length == 1 && layerRef.isBackgroundLayer == true)
{
alert("The Background layer cannot be hidden when it's the only layer in a document.");
}
else
{
numLayers = 1;
numLayers = Number(prompt("Number = ?","100","Number of layers per block?"));
for (var myCounter = myLayerCount; myCounter >= 0; myCounter--)
{
var myLayer = myDoc.layers[myLayerCount - myCounter]
var o = 0;
o = getImageAverageOpacity(myCounter);
myLayer.name = "Block " + blockNum;
myLayer.opacity = o;
if (o == 100) {blockNum = blockNum + 1};
}
if (confirm("Do you want to merge the visible layers now?"))
myDoc.mergeVisibleLayers();
}
}
function getImageAverageOpacity(LayerNum) {
var temp = LayerNum % numLayers;
var newOpacity = 100 * ( 1 / (1 + temp));
return newOpacity;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment