How to resize selection??

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

bamboo
Posts: 10
Joined: Fri Jul 29, 2016 7:14 pm

How to resize selection??

Post by bamboo »

How to resize selection??

what wrong with the code??

//
app.activeDocument.selection.selectAll()
app.activeDocument.selection.copy()
app.activeDocument.selection.resizeBoundary(50,300,AnchorPosition.MIDDLECENTER)

//
Attachments
v2.jpg
v2.jpg (150.56 KiB) Viewed 11760 times
v1.jpg
v1.jpg (42.73 KiB) Viewed 11760 times
User avatar
txuku
Posts: 136
Joined: Thu Jan 01, 1970 12:00 am

Re: How to resize selection??

Post by txuku »

Bonjour

You can use Methods
contract()
expand()

docRef.selection.expand(1) ( 1 pixel )
docRef.selection.contract(1)
bamboo
Posts: 10
Joined: Fri Jul 29, 2016 7:14 pm

Re: How to resize selection??

Post by bamboo »

Thank you Txuku

but I want make the selections value=3mm


have any way ??
User avatar
txuku
Posts: 136
Joined: Thu Jan 01, 1970 12:00 am

Re: How to resize selection??

Post by txuku »

Hum ...........

It seems to me that

You have to calculate it ??? :D
bamboo
Posts: 10
Joined: Fri Jul 29, 2016 7:14 pm

Re: How to resize selection??

Post by bamboo »

I don't know the other way!!
User avatar
txuku
Posts: 136
Joined: Thu Jan 01, 1970 12:00 am

Re: How to resize selection??

Post by txuku »

Bonjour

After research I think it is better to avoid the method
SelectAll() and select the document with at least one pixel.

Then the resizeBoundary () and other methods work without errors

Test this:

Code: Select all

startRulerUnits = app.preferences.rulerUnits;
startTypeUnits = app.preferences.typeUnits;
startDisplayDialogs = app.displayDialogs;
var docRef = app.activeDocument;

app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS;
app.displayDialogs = DialogModes.NO;

var largeur = docRef.width.as('px');
//alert(largeur)

app.preferences.rulerUnits = Units.PIXELS//CM//PIXELS
//app.preferences.typeUnits = TypeUnits.PIXELS//CM
app.displayDialogs = DialogModes.NO;

var largeur = docRef.width.as('px')//px'); ou as('mm')
var hauteur = docRef.height.as('px');
//alert(largeur)

//Selection : la taille de l image moins 1 px - selectAll() ne passe pas

LEFT = 0;
RIGHT = largeur-1;
TOP = 0
BOTTOM = hauteur-1;

var shapeRef = [
[LEFT,TOP],
[LEFT,BOTTOM],
[RIGHT,BOTTOM],
[RIGHT,TOP]
]

app.activeDocument.selection.select(shapeRef);

app.activeDocument.selection.resizeBoundary(50,300,AnchorPosition.MIDDLECENTER)

app.preferences.rulerunits = startRulerUnits;
app.preferences.typeunits = startTypeUnits;
app.displayDialogs = startDisplayDialogs;
wasfiwasfi
Posts: 45
Joined: Fri Nov 04, 2016 8:29 am

Re: How to resize selection??

Post by wasfiwasfi »

am not an expert but am pretty sure the easiest way is to get the "Boundary" (Bound) of the current selection , delete it and then create a new selection after doing the required modifications/resizing !
pixxxelschubser
Posts: 26
Joined: Mon Aug 01, 2016 8:59 pm

Re: How to resize selection??

Post by pixxxelschubser »

wasfiwasfi wrote:am not an expert but am pretty sure the easiest way is to get the "Boundary" (Bound) of the current selection , delete it and then create a new selection after doing the required modifications/resizing !
Yes.
I'm totally agree with you.
User avatar
txuku
Posts: 136
Joined: Thu Jan 01, 1970 12:00 am

Re: How to resize selection??

Post by txuku »

Undoubtedly ........ exact! :oops:
bamboo
Posts: 10
Joined: Fri Jul 29, 2016 7:14 pm

Re: How to resize selection??

Post by bamboo »

Thank you txuku!!