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.
Copy link to clipboard
Copied
Please show the image.
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.?
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.
Copy link to clipboard
Copied
Thank you hhas01..