InDesign CC 2014自動化作戦 (InDesign CC 2014 Automation Operation)

画像の座標を表示する

■プログラム説明(ソースコード説明)
 画像のフレームの座標を求めるにはgeometricBoundsまたはvisibleBounds配列を参照します。順番にy1,x1,y2,x2の座標の順番で入っています。値は単位のなしで、現在設定されている単位での値になります。

■ソースコード
imgObj = app.activeDocument.selection[0];
x1 = imgObj.geometricBounds[1];
y1 = imgObj.geometricBounds[0];
x2 = imgObj.geometricBounds[3];
y2 = imgObj.geometricBounds[2];
alert("("+x1+","+y1+")-("+x2+","+y2+")");


■使い方
1:座標を表示する画像を選択します。
2:スクリプトを実行します。
3:座標が表示されます。


■ポイント
 visibleBoundsの場合は以下のようになります。

imgObj = app.activeDocument.selection[0];
x1 = imgObj.visibleBounds[1];
y1 = imgObj.visibleBounds[0];
x2 = imgObj.visibleBounds[3];
y2 = imgObj.visibleBounds[2];
alert("("+x1+","+y1+")-("+x2+","+y2+")");

■実際のスクリプトをダウンロード(sample.jsx.zip)

写真素材 PIXTA