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

Automatically place guides

Community Beginner ,
Sep 22, 2020 Sep 22, 2020

Copy link to clipboard

Copied

Hello,

I need to place one simple vertical guide between the highest points of my image but automatically? Is there any trick for that? The size of the image will be always different but it will always have two highest points.

 

Bez názvu-2.jpg

TOPICS
Actions and scripting

Views

852

Translate

Translate

Report

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

correct answers 1 Correct answer

People's Champ , Sep 23, 2020 Sep 23, 2020
Not the most accurate way. Often it does not produce what is expected.
 
...

Votes

Translate

Translate
Adobe
Advocate ,
Sep 23, 2020 Sep 23, 2020

Copy link to clipboard

Copied

Script idea...

- make a selection of your object

- convert selection to a path

- compare y-values of the anchor points to find top most anchor point (lowest value).

- place vertical guide to x-value of top most anchor point

Votes

Translate

Translate

Report

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 Beginner ,
Sep 23, 2020 Sep 23, 2020

Copy link to clipboard

Copied

I get it but I have no idea how to make a script. (no experience with java)

Votes

Translate

Translate

Report

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
People's Champ ,
Sep 23, 2020 Sep 23, 2020

Copy link to clipboard

Copied

Not the most accurate way. Often it does not produce what is expected.
 

Votes

Translate

Translate

Report

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 Beginner ,
Sep 23, 2020 Sep 23, 2020

Copy link to clipboard

Copied

Oh my. Thats great, it is actually working.  Just one thing, I found out that if there are multiple highest points in the same row, the guide will show itself right in the middle of the first and last one.

 

Would it be possible to edit that script so it would "subtract one half of the path created by the highest points so the guide moves itself to the first highest point?" - attached pic below, I need to get the guide where the black arrow points.

 


Bez názvu-1.jpg 

Votes

Translate

Translate

Report

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
People's Champ ,
Sep 24, 2020 Sep 24, 2020

Copy link to clipboard

Copied

Pay attention to the third line from the end. This is where the middle of the selection is set (on purpose). Think and change the code yourself.
 

Votes

Translate

Translate

Report

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 Beginner ,
Sep 24, 2020 Sep 24, 2020

Copy link to clipboard

Copied

Third line from the end? You mean the word "intersect"? Sorry I just dont know java coding or what kind of words should I replace.

Votes

Translate

Translate

Report

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
People's Champ ,
Sep 24, 2020 Sep 24, 2020

Copy link to clipboard

Copied

Well.

Try replace

(app.activeDocument.selection.bounds[0]+app.activeDocument.selection.bounds[2])/2

 

with

 

app.activeDocument.selection.bounds[0]

 

Helped?

 

 

P.S.

The accuracy of the guide is still questionable.
Depends on shape and edge blur.
 

Votes

Translate

Translate

Report

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 Beginner ,
Sep 24, 2020 Sep 24, 2020

Copy link to clipboard

Copied

You are my hero. Thanks.

Votes

Translate

Translate

Report

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 ,
Sep 24, 2020 Sep 24, 2020

Copy link to clipboard

Copied

Paranoic, I think it is about time that you familiarise yourself with Photoshop Scripting some more. 

Votes

Translate

Translate

Report

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 Beginner ,
Sep 24, 2020 Sep 24, 2020

Copy link to clipboard

Copied

LATEST

I know but I dont have time for such learning. I would rather pay a professional who would made me some individual scripts because there is much more I need 😕

Votes

Translate

Translate

Report

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
People's Champ ,
Sep 24, 2020 Sep 24, 2020

Copy link to clipboard

Copied

More accurate script. Use when there is blurred edges.
 
var old_units = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;

var d = new ActionDescriptor();
var r = new ActionReference();
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
d.putReference(stringIDToTypeID("null"), r);
var r1 = new ActionReference();
r1.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("transparencyEnum"));
d.putReference(stringIDToTypeID("to"), r1);
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);

app.activeDocument.quickMaskMode = true;

var d = new ActionDescriptor();
d.putInteger(stringIDToTypeID("level"), 128);
executeAction(stringIDToTypeID("thresholdClassEvent"), d, DialogModes.NO);

app.activeDocument.quickMaskMode = false;

var x0 = app.activeDocument.selection.bounds[0].value;
var x1 = app.activeDocument.selection.bounds[2].value;
var y0 = app.activeDocument.selection.bounds[1].value;

app.activeDocument.selection.select([[x0,y0], [x1,y0], [x1,y0+1], [x0,y0+1]], SelectionType.INTERSECT);

app.activeDocument.guides.add(Direction.VERTICAL, app.activeDocument.selection.bounds[0], SelectionType.INTERSECT);

app.activeDocument.selection.deselect();

app.preferences.rulerUnits = old_units;

Votes

Translate

Translate

Report

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