スクリーンキャプチャを行うメソッドimageCapture

最終更新日

Comments: 0

全く雨がふらず日照り続きでどうしたもんだって思ってたら今度は晴れないって、どうしたものでしょう。皆様も通勤大変だと思いますが、いかがお過ごしでしょうか。
昨日某ショッピングセンターの育樹祭に参加してきたのですが、イラガの幼虫にやられましたw
久しぶりに痛い思いをしました。しかし、チャドクガなんかとは違い毒針毛が残りませんので数時間も経てば炎症も引いてどこを刺されたのかもわからなくなるのですが、痛かったです。

少し立込んでいてな〜んにも書いてませんがScripting Forumとかは時折フォローしている次第です。そこでimageCaptureメソッドなるものを初めて知った次第です。

元スレッドはhttps://forums.adobe.com/thread/2211864です。相変わらずカルロスが良い仕事しています。

さて、OMVで調べるとdocumentのメソッドとしてimageCaptureが存在するのですが、引用してみましょう。

Document.imageCapture (imageFile: File , clipBounds: Rect , options: ImageCaptureOptions ) 

 Adobe Illustrator 20 Type Library 

 Capture the artwork content inside the clip bound as raster image, and write out the captured image data into the target image file.

 imageFile: Data Type: File 

 The file to which the captured image should be written.

 clipBounds (optional): Data Type: Rect 

 The rectangular region of the artwork for image capture. If the parameter is omitted, the entire artwork bound is captured.
 options (optional): Data Type: ImageCaptureOptions 

 Describes the image capture options.

とあります。

引数をざっと見てみます。

imageFileは保存先ファイルオブジェクト、clipBoundsはRectとして与えられるキャプチャする対象となる四角のエリア、captureOptionは書き出し時のpngファイルのコンディションに関するオプションを定義する為のオブジェクトとなっています。

Illustratorの場合、Rectは[left,top,right,bottom]で定義されます。通常はアートボード毎に書き出すとかしますからartboardRectをそのまま放り込む事が多そうです。

captureOptionですが、以下の5つのプロパティが存在します。

antiAliasing(Boolean) アンチエイリアス。デフォルトはfalse

matte(Boolean) 背景。デフォルトはfalse

transparency(Boolean) 透明。デフォルトはfalse

matteColo(RGBColorオブジェクト) 背景色 デフォルトは#FFFの白です。

resolution(Real) 解像度です。デフォルトでは150ppiになっています。

サンプルです。

var fl = File('~/Desktop/testQR.png');

 var captureOpts = new ImageCaptureOptions;

 captureOpts.matte = true;

 captureOpts.antiAliasing = true;

 captureOpts.resolution = 96;

 app.activeDocument.imageCapture (image, app.activeDocument.artboards[0].artboardRect, captureOpts);

captureOptionsはデフォルトがfalseだらけですから必ず指定しましょう。

アートボードの状態はこんな感じ

キャプチャしたのがこの画像です。

ten_a

Graphic Designer, Scripter and Coder. Adobe Community Professional.

シェアする

コメントを残す