Skip to content

Instantly share code, notes, and snippets.

@kanemu
Created May 19, 2010 01:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kanemu/405831 to your computer and use it in GitHub Desktop.
Save kanemu/405831 to your computer and use it in GitHub Desktop.
[indesign][extendscript]画像の幅と高さを取るサンプル、画像をフィットさせるサンプル
/*
fitimage_ind.jsx
画像の幅と高さを取るサンプル
画像をフィットさせるサンプル
※ピクセルサイズを取るのはInDesignでは無理
*/
//画像の入ったフレームを選択
var sel=app.activeDocument.selection[0];
//中の画像
var img=sel.allGraphics[0];
//プロパティ全部確認
//$.writeln(img.properties.toSource().replace(/,/g,",\n"));
var bounds=img.geometricBounds;
var w=(bounds[3]-bounds[1])/img.horizontalScale*100;//幅
var h=(bounds[2]-bounds[0])/img.verticalScale*100;//高さ
$.writeln('W:'+w+',H:'+h);
img.fit(FitOptions.PROPORTIONALLY);
/*
FitOptions.CENTER_CONTENT
FitOptions.CONTENT_TO_FRAME
FitOptions.FILL_PROPORTIONALLY
FitOptions.FRAME_TO_CONTENT
FitOptions.PROPORTIONALLY
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment