Retrieve the details of shear angle, horizontal scale and vertical scale.

New Here ,
Apr 05, 2022 Apr 05, 2022

Copy link to clipboard

Copied

Hiii everyone, I'm trying to retrieve the details of shear angle, horizontal scale and vertical scale Of the image in illustrator. Please help me to get the solution. Thank you. 

TOPICS
Scripting

Views

196

Likes

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

Contributor , Apr 06, 2022 Apr 06, 2022
First question: How’s your math? (Personally I forgot all mine decades ago, and even those who know geometry think Adobe’s is weird, so caveat emptor, E&OE, etc.) Anyway, welcome to the `matrix` property: var image = app.activeDocument.placedItems[0] var matrix = image.matrix This will give you information on the transformation that’s currently applied to the image†. Everything after this will give you a headache. Here’s a good overview: http://www.senocular.com/flash/tutorials/transformmatrix/...

Likes

Translate

Translate
Adobe Community Professional ,
Apr 06, 2022 Apr 06, 2022

Copy link to clipboard

Copied

Please show the image.

Likes

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
New Here ,
Apr 06, 2022 Apr 06, 2022

Copy link to clipboard

Copied

Hi Monika Gause ,thank for the reply , my question is, if the image has applied shear angle, horizontal scale and vertical scale. in this scenario how can we retrieve those details(shear angle,horizontal scale and vertical scale.) in illustrator using script.?

Likes

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
Contributor ,
Apr 06, 2022 Apr 06, 2022

Copy link to clipboard

Copied

First question: How’s your math?

 

(Personally I forgot all mine decades ago, and even those who know geometry think Adobe’s is weird, so caveat emptor, E&OE, etc.)

 

Anyway, welcome to the `matrix` property:

 

 

var image = app.activeDocument.placedItems[0]

var matrix = image.matrix

 

 

This will give you information on the transformation that’s currently applied to the image†. Everything after this will give you a headache.

 

Here’s a good overview:

 

http://www.senocular.com/flash/tutorials/transformmatrix/

 

It talks about Flash but the principles are the same. To summarize, a matrix object has 4 properties describing how the image is transformed (plus an extra 2 that can be used to move it around which aren’t relevant here):

 

mValueA: x scale
mValueB: y skew
mValueC: x skew
mValueD: y scale

 

Second question: for what purposes do you need this information?

 

e.g. To remove all transformations from an image:

 

 

var matrix = new Matrix()

matrix.mValueA = 1.0
matrix.mValueB = 0.0
matrix.mValueC = 0.0
matrix.mValueD = 1.0

image.matrix = matrix

 

 

Or to de-rotate the image while leaving its scale and skew unchanged:

 

 

var image = app.activeDocument.rasterItems[0]

var matrix = image.matrix

var angle = Math.atan2(matrix.mValueB, matrix.mValueA)

var angleInDegrees = angle / Math.PI * 180

image.rotate(-angleInDegrees)

 

 

Or to remove all skew (which also effectively removes the rotation, since one is the product of the other):

 

 

var matrix = image.matrix
matrix.mValueB = 0
matrix.mValueC = 0
image.matrix = matrix

 

 

And so on. If you want to copy the image’s transformation matrix to other objects, or apply further transforms, you can do that too. See the Matrix object in Illustrator’s Scripting Reference, and the various matrix math commands on the app object.

 

OTOH, if you wish to know precisely what x scale, y scale, x skew, y skew, and rotation values the artist originally applied to the image, you will have to ask them that. It’s impossible to convert the 4 matrix values (A,B,C,D) back to those original 5‡, as any one transformation may be produced from any number of different combinations of scale, skew, and rotation numbers.

 

But anyway, that’s enough of that. Hope it helps, and pass the asprin.

 

--

 

† Use `rasterItems[n]` if the image is embedded instead of linked (`placedItems[n]`). Or just `pageItems[n]` if you don’t care.

 

‡ Simultaneous equations are an implacable mistress. You’ll have to pin down values for 2 of the variables before you can calculate the rest.

Likes

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
New Here ,
Apr 08, 2022 Apr 08, 2022

Copy link to clipboard

Copied

LATEST

Thank you hhas01.. 

Likes

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