Last active
October 16, 2023 09:45
-
-
Save kulmajaba/ce4064b8a170f8a543d6dd1945e8d4f0 to your computer and use it in GitHub Desktop.
Stack layers and increment opacity to create a fading star trail effect.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a file in the path "Adobe Photoshop 2022/Presets/Scripts/Star Trails.jsx" and paste the contents there to use | |
// Star Trails, author Mika Kuitunen | |
// DEBUGGING STUFF | |
function ConsoleLog() { | |
// Seeing logs: macOS: nc -lvk 8000, Win: install Ncat, then ncat -lk 8000 | |
this.socket = new Socket(); | |
this.hostPort = "127.0.0.1:8000"; | |
} | |
ConsoleLog.prototype.log = function(logMessage){ | |
if (!debug) return; | |
if (this.socket.open(this.hostPort)){ | |
this.socket.write (logMessage + "\n"); | |
this.socket.close(); | |
} | |
}; | |
var debug = false; | |
var console = new ConsoleLog(); | |
// on localized builds we pull the $$$/Strings from a .dat file | |
$.localize = true; | |
// Put header files in a "Stack Scripts Only" folder. The "...Only" tells | |
// PS not to place it in the menu. For that reason, we do -not- localize that | |
// portion of the folder name. | |
var g_StackScriptFolderPath = app.path + "/"+ localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts") + "/" | |
+ localize("$$$/private/LoadStack/StackScriptOnly=Stack Scripts Only/"); | |
$.evalFile(g_StackScriptFolderPath + "LatteUI.jsx"); | |
$.evalFile(g_StackScriptFolderPath + "StackSupport.jsx"); | |
$.evalFile(g_StackScriptFolderPath + "CreateImageStack.jsx"); | |
/************************************************************/ | |
// loadLayers routines | |
loadLayers = new ImageStackCreator(localize("$$$/AdobePlugin/Shared/LoadStack/Process/Name=Load Layers"), | |
localize('$$$/AdobePlugin/Shared/LoadStack/Auto/untitled=Untitled')); | |
// LoadLayers is less restrictive than MergeToHDR | |
loadLayers.mustBeSameSize = false; // Images' height & width don't need to match | |
loadLayers.mustBeUnmodifiedRaw = false; // Exposure adjustements in Camera raw are allowed | |
loadLayers.mustNotBe32Bit = false; // 32 bit images | |
loadLayers.createSmartObject = false; // If true, option to create smart object is checked. | |
loadLayers.mustNotBeSmartObj = false; | |
loadLayers.stackLayers = function() | |
{ | |
var result, i, stackDoc = null; | |
stackDoc = this.loadStackLayers(); | |
if (! stackDoc) | |
return; | |
// Nuke the "destination" layer that got created (M2HDR holdover) | |
stackDoc.layers[this.pluginName].remove(); | |
var layers = stackDoc.layers; | |
var max = layers.length; | |
var k = 0; | |
for (var j = layers.length - 1; j >= 0; j--) { | |
layers[j].blendMode = BlendMode.LIGHTEN; | |
layers[j].opacity = (100.0 / (k + 1)) * (k / max + 1); | |
k++; | |
} | |
} | |
// "Main" execution of Merge to HDR | |
loadLayers.doInteractiveLoad = function () | |
{ | |
this.getFilesFromBridgeOrDialog(localize("$$$/private/LoadStack/LoadLayersexv=LoadLayers.exv")); | |
if (this.stackElements) | |
this.stackLayers(); | |
else | |
return 'cancel'; | |
} | |
loadLayers.intoStack = function(filelist, alignFlag) | |
{ | |
if (typeof(alignFlag) == 'boolean') | |
loadLayers.useAlignment = alignFlag; | |
if (filelist.length < 2) | |
{ | |
alert(localize("$$$/AdobeScripts/Shared/LoadLayers/AtLeast2=At least two files must be selected to create a stack."), this.pluginName, true); | |
return; | |
} | |
var j; | |
this.stackElements = new Array(); | |
for (j in filelist) | |
{ | |
var f = filelist[j]; | |
this.stackElements.push(new StackElement((typeof(f) == 'string') ? File(f) : f)); | |
} | |
if (this.stackElements.length > 1) | |
this.stackLayers(); | |
} | |
if (typeof(loadLayersFromScript) == 'undefined') | |
loadLayers.doInteractiveLoad(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment