Help with photoshop JavaScript (for seamless textures)

Discuss anything you like on this forum.
Post Reply
prehabitat
Licensed Customer
Posts: 495
Joined: Fri Aug 16, 2013 10:30 am
Location: Victoria, Australia

Hi All,

I'm pretty much constantly trying to get tools/actions/etc together to help processing images(and other things) quicker. I have a heap of time-saving Photoshop actions already; and add to them often; but always find myself hitting a barrier when trying to plan any algorithm where I want/need to refer to relative adjustments which arnt available natively in PS(rather than absolutes; which are easier generally).
I think I'm going to have to get into some coding/scripting to take it to the next level.

Below I have a code snipped I've 'found' which will solve my immediate problem and allow a soft entry into coding via an immediately useful example - namely; it offsets the image by half the px Width & Height of the image (useful once you have a square image that you want to make seamless).

example code snippet:

Code: Select all

// Save the current preferences 
 var startRulerUnits = app.preferences.rulerUnits; 
 var startTypeUnits = app.preferences.typeUnits; 
 var startDisplayDialogs = app.displayDialogs; 

 // Set Photoshop to use pixels as the unit value/rulers and display no dialogs 
 app.preferences.rulerUnits = Units.PIXELS; 
 app.preferences.typeUnits = TypeUnits.PIXELS; 
 app.displayDialogs = DialogModes.NO; 

 var id164 = charIDToTypeID( "Ofst" ); 
 var desc49 = new ActionDescriptor(); 
 var id165 = charIDToTypeID( "Hrzn" ); 
 // We want to offset by a percentage so take the document dimensions in pixels 
 // and multiply it by the floating point percentage value in order to give the offset 
 // scripting listener code the amount in pixels, since that's what it expects 
 desc49.putInteger( id165, app.activeDocument.width * .5 ); 
 var id166 = charIDToTypeID( "Vrtc" ); 
 desc49.putInteger( id166, app.activeDocument.height * .5); 
 var id167 = charIDToTypeID( "Fl" ); // This line is highlighted in debug mode after I've try to play the script.
 var id168 = charIDToTypeID( "FlMd" ); 
 var id169 = charIDToTypeID( "Wrp " ); 
 desc49.putEnumerated( id167, id168, id169 ); 
 executeAction( id164, desc49, DialogModes.NO ); 

 preferences.rulerUnits = startRulerUnits; 
 preferences.typeUnits = startTypeUnits; 
 displayDialogs = startDisplayDialogs; 
As above; the script stops at the line with "var id167 = charIDToTypeID( "Fl" );" I understand the concept of objects and can work out a little further than that; but I don't understand all of the above, esp. Vrtc, Fl, FlMd, Wrp in the Var ID #166-169. Certainly not enough to be able to debug the issue.

Does anyone know JavaScript (and its use within the Photoshop environment) enough to help with the above?

I am also interested how I can package and call up the script once it works; but that's prob a pretty basic fundamental I can research myself...
Win10/3770/16gb/K600(display)/GTX780(Octane)/GTX590/372.70
Octane 3.x: GH Lands VARQ Rhino5 -Rhino.io- C4D R16 / Revit17
Post Reply

Return to “Off Topic Forum”