Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Building my own Plug-in Filter

New Here ,
May 11, 2020 May 11, 2020

I am in the process of writing a plug-in filter in Adobe Photoshop and have the following question: Is it possible for a  plug-in filter to determine the pixel position (upper left corner, for example) of the passed in image via FilterRecord relative to the “main” image displayed in photoshop?   

TOPICS
Actions and scripting
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
May 11, 2020 May 11, 2020

I do not know actually what you are asking. However I would  think that any image passed is mass as a rectangle canvas where 0,0 will be top left  and width, height the bottom right.  If the image is being pass is a layer in the current document the.  Its relative  document position would also be included it may even be outside the document canvas.

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 11, 2020 May 11, 2020

And Layers’ bounds can be evaluated with JavaScript both via the DOM and AM-code. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 11, 2020 May 11, 2020
LATEST

Here is the script code for the current layer  the script will set guides for the layers bounds and its center and an display the  layer information.

image.png

 

// enable double-clicking from Mac Finder or Windows Explorer
#target photoshop // this command only works in Photoshop CS2 and higher

// bring application forward for double-click events
app.bringToFront();

// Save the current preferences
var startRulerUnits = app.preferences.rulerUnits;
// Set Photoshop to use pixels 
app.preferences.rulerUnits = Units.PIXELS;

try{
	var LB = activeDocument.activeLayer.bounds;
	var LWidth = (LB[2].value) - (LB[0].value);
	var LHeight = (LB[3].value) - (LB[1].value);
	MarkX((LB[0].value + LWidth/2));
	MarkX(LB[0].value);
	MarkX(LB[2].value);
	MarkY((LB[1].value + LHeight/2));
	MarkY(LB[1].value)	
	MarkY(LB[3].value)
	alert("'" + activeDocument.activeLayer.name + "' Layer Bounds\nTop Left " +  LB[0].value + "X," +  LB[1].value + "Y   Bottom Right "  +  LB[2].value + "X," +  LB[3].value
		+ "Y\nWidth " +  LWidth + "px   Height " + LHeight +"px" 
		+ "\nLayer center relative to canvas " + (LB[0].value + LWidth/2) + "X," +  (LB[1].value + LHeight/2) +"Y" 
		, "Layer Bounds Info");
}
catch(e){alert("Requires a layer targered");}

// Return the app preferences
app.preferences.rulerUnits = startRulerUnits;
function MarkX(x) {
// =======================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc61 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
        var desc62 = new ActionDescriptor();
        var idPstn = charIDToTypeID( "Pstn" );
        var idPxl = charIDToTypeID( "#Pxl" );
        desc62.putUnitDouble( idPstn, idPxl, x);
        var idOrnt = charIDToTypeID( "Ornt" );
        var idOrnt = charIDToTypeID( "Ornt" );
        var idVrtc = charIDToTypeID( "Vrtc" );
        desc62.putEnumerated( idOrnt, idOrnt, idVrtc );
    var idGd = charIDToTypeID( "Gd  " );
    desc61.putObject( idNw, idGd, desc62 );
executeAction( idMk, desc61, DialogModes.NO );
}
function MarkY(y) {
// =======================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc63 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
        var desc64 = new ActionDescriptor();
        var idPstn = charIDToTypeID( "Pstn" );
        var idPxl = charIDToTypeID( "#Pxl" );
        desc64.putUnitDouble( idPstn, idPxl, y );
        var idOrnt = charIDToTypeID( "Ornt" );
        var idOrnt = charIDToTypeID( "Ornt" );
        var idHrzn = charIDToTypeID( "Hrzn" );
        desc64.putEnumerated( idOrnt, idOrnt, idHrzn );
    var idGd = charIDToTypeID( "Gd  " );
    desc63.putObject( idNw, idGd, desc64 );
executeAction( idMk, desc63, DialogModes.NO );
}

 

 

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines