ファイルを選択しそのファイルを新規ドキュメントに配置し適切なサイズにドキュメントサイズを変更した後選択ファイルのフォルダに保存する。
set this_item to choose file with prompt "配置ファイルを選択"
set Fpath to this_item as string
--変数Fpathにフルパスを入れる
set Fpath to Fpath & ".indd"
--フルパスに拡張子.inddを付けておく
set Finfo to info for this_item
--ファイルインフォメーションを調べる
set FType to file type of Finfo
--ファイルインフォメーションのファイルタイプを変数Ftypeに入れる
set Fkind to kind of Finfo
--ファイルインフォメーションのファイルカインドを変数Fkindに入れる
--↓下記のような条件があえば。。。意外と条件にあわないEPSが多い。
if FType is "EPSF" or FType is "EPSP" or FType is "PDF " or FType is "8BPS" ¬
or FType is "TEXT" or Fkind is "Adobe Photoshop ファイル" or ¬
FType is "TIFF" or Fkind is "TIFF 書類" or Fkind is "EPS ファイル" then
--オリジナル関数setEPS2を呼び出す
my setEPS2(this_item, Fpath)
end if
--↓オリジナル関数setEPS2
on setEPS2(this_item, Fpath)
tell application "Adobe InDesign CS2_J"
--ドキュメントを作成
make document
tell active document
set myRect to make rectangle at beginning with properties ¬
{geometric bounds:{0, 0, 100, 100}, ¬
stroke weight:0, fill color:"None", stroke color:"None"}
--とりあえずrectangle(ボックス)を作成100×100サイズ
--線や塗りはなし
set EPSobj to place this_item on myRect
--ファイルを作成したボックスに配置する
--(配置画像を変数EPSobjに入れる)
set myB to geometric bounds of EPSobj
--配置画像(変数EPSobj)の領域を調べる
--geometric bounds は{Y1,X1,Y2,X2}で返ってくる
set H to (item 3 of myB) - (item 1 of myB)--高さを取り出す
set W to (item 4 of myB) - (item 2 of myB)--幅を取り出す
if H < 297 and W < 210 then --A4縦より小さいなら
set PW to 210
set PH to 297
else if H < 210 and W < 297 then --A4横より小さいなら
set PW to 297
set PH to 210
else if H < 364 and W < 257 then --B4縦より小さいなら
set PW to 257
set PH to 364
else if H < 257 and W < 364 then --B4横より小さいなら
set PW to 364
set PH to 257
else --それ以外
if H > W then --A3縦
set PW to 297
set PH to 420
else --A3横
set PW to 420
set PH to 297
end if
end if
set properties of document preferences to {page height:PH, page width:PW}
--ドキュメントのサイズを変更する。
set geometric bounds of myRect to {0, 0, PH, PW}
--rectのサイズをページサイズにする
fit myRect given center content
--画像をセンターあわせにする。
save to Fpath
--Fpathに保存する。
end tell
end tell
end setEPS2
コメントする