Created
August 22, 2013 06:10
-
-
Save takezoux2/6303722 to your computer and use it in GitHub Desktop.
Illustratorで、選択しているオブジェクトをPNG画像として保存するスクリプト。
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
var doc = app.activeDocument; | |
var sels = doc.selection; | |
function saveAsPNG( doc , filename){ | |
var exportOptions = new ExportOptionsPNG24(); | |
var type = ExportType.PNG24; | |
var fileSpec = new File(filename); | |
exportOptions.antiAliasing = false; | |
exportOptions.transparency = false; | |
exportOptions.saveAsHTML = true; | |
doc.exportFile(fileSpec,type,exportOptions) | |
} | |
function createNewDocument(items ){ | |
var newDoc = app.documents.add(); | |
for(var i = 0; i < items.length;i++){ | |
var item = items[i]; | |
if(item.duplicate){ | |
var copy = item.duplicate(); | |
copy.moveToEnd(newDoc); | |
} | |
} | |
return newDoc; | |
} | |
function getDefaultName(items){ | |
for(var i = 0;i < items.length ; i++){ | |
var n = items[i].name; | |
if(n != null && n.length > 0){ | |
return n; | |
} | |
} | |
return null; | |
} | |
if(sels.length == 0){ | |
alert("オブジェクトを選択してください。"); | |
}else{ | |
var filename = File.saveDialog("保存ファイル","*.png"); | |
if(filename){ | |
alert(filename); | |
var doc = createNewDocument(sels); | |
saveAsPNG(doc,filename); | |
doc.close(SaveOptions.DONOTSAVECHANGES); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment