Created
April 18, 2025 03:53
-
-
Save monokano/08bcf589ebd9748d45734c077ba22d7a to your computer and use it in GitHub Desktop.
アクティブなアートボードをキャプチャするIllustrator用スクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // アクティブなアートボードをキャプチャします | |
| // デスクトップにpngファイルを保存します | |
| // カラープロファイルは埋め込まれませんが、作業用RGBになります | |
| // こちらの記事を元にしました https://ten-artai.com/2016/09/337/ | |
| // 日時を元に一意のファイル名を生成 | |
| function getTimestamp() { | |
| var now = new Date(); | |
| var yyyy = now.getFullYear(); | |
| var mm = ("0" + (now.getMonth() + 1)).slice(-2); | |
| var dd = ("0" + now.getDate()).slice(-2); | |
| var hh = ("0" + now.getHours()).slice(-2); | |
| var min = ("0" + now.getMinutes()).slice(-2); | |
| var ss = ("0" + now.getSeconds()).slice(-2); | |
| return yyyy + mm + dd + "_" + hh + min + ss; | |
| } | |
| // ファイルパス生成(デスクトップ) | |
| var timestamp = getTimestamp(); | |
| var desktopFolder = Folder.desktop; // クロスプラットフォーム対応 | |
| var fileName = "artboard-capture_" + timestamp + ".png"; | |
| var f = new File(desktopFolder.fsName + "/" + fileName); | |
| // 保存ファイルパスを表示(デバッグ用) | |
| //alert("保存ファイルパス:\n" + f.fsName); | |
| // オプション | |
| var captureOpts = new ImageCaptureOptions; | |
| captureOpts.resolution = 144; //解像度 | |
| captureOpts.antiAliasing = true; //アンチエイリアスON | |
| captureOpts.transparency = false; //背景透明OFF | |
| var doc = app.activeDocument; | |
| var rect = doc.artboards[doc.artboards.getActiveArtboardIndex()].artboardRect; | |
| doc.imageCapture(f, rect, captureOpts); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment