Photoshop: Ability to Offset in percentage increments

  • 2
  • Idea
  • Updated 6 years ago
  • (Edited)
As a 3D artist the only time I ever use the 'offset' filter tool is to create seamless textures. However doing so means that every time I have to open up notepad, write down the pixel dimensions of the image, open up the calculator (as I'm terrible at maths) divide by two and then put those numbers into the offset dialog box to get the centre of the image. Could you have an option in the offset features dialog box to automatically offset by 50%? I guess it would need to be grayed out if the image wasn't an even number of pixels?
Photo of Nick Macmillan

Nick Macmillan

  • 1 Post
  • 0 Reply Likes

Posted 6 years ago

  • 2
Photo of Jeffrey Tranberry

Jeffrey Tranberry, Sr. Product Manager, Digital Imaging

  • 13635 Posts
  • 1546 Reply Likes
This should work to do what you want:

// 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 " );
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;