TeamPhotoshop
Reviews, updates and in depth guides to your favourite mobile games - AppGamer.com
Forum Home Latest Posts Search Help Subscribe

Action Script for Specialized Border Question

Page: 1 Reply
Feb 8th 2007#176207 Report
Member since: Feb 8th 2007
Posts: 2
Hello. I'm new to photoshop, and have read the scripting books. But I can't figure out how to do the following process.

I want to create a PARTIAL frame to process for images of various sizes. Specifically, I have several thousand images of various sizes, and I need to create a 1-pixel width frame around the image, with the EXCEPTION of the bottom border, as well as 25 pixels from the bottom of the image.

Currently, I'm using a recorded action that selects the image, the inserts a 1-pixel black frame around the INSIDE part of the image (Stroke method). That part is easy. But what I need to have done is to omit the bottom border, as well as 25 pixels from the bottom on each side border.

Here are two images with full frames, using the Inside Stroke 1 pixel method. Note that both images are different sizes.





What I need NOW is to further modify the image to remove parts of the border as below:





Note that the image can be varying heights and widths, of which no height or width of the image is under 75 pixels. Nevertheless, i need a consistent result as above.

Can anyone provide a basic direction for me to go in? I am used to VB Script, but can also do Java as that seems to be the preferred method (I assume that this will require a script).

EDIT: Just for clarification, the pixels left after the border part is removed can either be transparent or the color white (as shown in the sample). The finished product will always go on a white background, so white pixels are ok.
Reply with Quote Reply
Feb 9th 2007#176209 Report
Member since: Mar 27th 2001
Posts: 2237
I think you are going to have to create an action for part of it. You are in luck however, I needed just almost exactly what you are asking for not 3 months ago.

The following code was stolen from various places around the internet. :D


Call this script from your action to put a 1 pixel border around the image.

[CODE]
// run script in Photoshop
#target photoshop;

// debugging code
/*
debugger;
$.level = 1;
*/

displayDialogs = DialogModes.NO;
var defaultRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;



var AD = activeDocument;
var resRatio = AD.resolution/72;

if(resRatio!=1){
AD.resizeImage(AD.width,AD.height,72);
}

//var heightVar = AD.height+2;

var black = new SolidColor();
black.rgb.red = black.rgb.green = black.rgb.blue = 0;

var white = new SolidColor();
white.rgb.red = white.rgb.green = white.rgb.blue = 255;

backgroundColor = black;
AD.resizeCanvas(AD.width+2,AD.height+1,AnchorPosition.BOTTOMCENTER);


AD.flatten();
[/CODE]

Then run the same script again with a some adjustments.

You'll have to change the background color.... or it will put a 25px black border on the bottom.

AND

Replace:
[CODE]
AD.resizeCanvas(AD.width+2,AD.height+1,AnchorPosition.BOTTOMCENTER);
[/CODE]

With:
[CODE]
AD.resizeCanvas(AD.width,AD.height+25,AnchorPosition.TOPCENTER);
[/CODE]

Hope this helps.
Reply with Quote Reply
Feb 14th 2007#176294 Report
Member since: Feb 8th 2007
Posts: 2
It didn't quite do what I needed. It was adding 25 pixels to the bottom of the image, and was creating the pixel on the outside of the image

However, let me loosen up the requirement. I would just like to take an image and create a 1-pixel width border around the INSIDE of the image, with the exception that the bottom border be placed 25 pixels of the image bottom. The effect I want to achieve is below:






This is actually equivalent to the original request, with the exception of the bottom border. I actually prefer a VB script over an action, but will take anything that automates this process for over 20,000 images. Thanks for your help! Anyone need any database help, let me know.
Reply with Quote Reply
Page: 1 Back to top
Please login or register above to post in this forum