Skip to content

Instantly share code, notes, and snippets.

@moluapple
moluapple / ID_getAllTables.jsx
Created December 21, 2011 04:43
ID_Get All Tables of ActiveDocument
function extractAllTables () {
var oTables = [];
function getTables (oParent) {
var outTables = oParent[oParent.constructor.name == 'Table' ? 'cells' : 'stories'].everyItem().tables.everyItem().getElements(),
len = outTables.length,
i = 0;
oTables = oTables.concat(outTables);
for (; i < len; i++) outTables[i].cells.everyItem().tables.everyItem().getElements().length && getTables(outTables[i]);
}
getTables(app.activeDocument);
@moluapple
moluapple / 按文件名搜寻并链接图像.jsx
Created November 29, 2011 10:04
Indesin_Search&Link Embed Image by Filename
(function (){
app.findGrepPreferences.findWhat = '~a\r.+';
var d = app.activeDocument,
f = Folder.selectDialog ('选中图像根目录文件夹'),
R = d.findGrep(),
RL = R.length, i = 0;
for (; i < RL; i++){
var images = getFileFromFolder(f, R[i].contents.match(/\S{2,}/)[0]),
real;
@moluapple
moluapple / gist:1385381
Created November 22, 2011 10:29
PS_Split Channels to Files
(function (){
var op = new TiffSaveOptions;
op.imageCompression = TIFFEncoding.TIFFLZW;
app.documents.length == 1 && splitChannels (activeDocument);
function splitChannels (doc) {
var fn = doc.name,
fp = doc.path,
md = doc.mode,
base = fn.replace(/\.\w{2,4}$/, ''),
@moluapple
moluapple / PS_MergeChannelsFromFiles.jsx
Created November 2, 2011 11:48
PS_Merge Multiple Single-Channel-Files to One Multi-Channels File
(function (){
var f = Folder.selectDialog ('选择文件夹'),
fA = f.getFiles ('*.tif'),
fs = f.fsName,
op = new TiffSaveOptions,
i = 0;
op.imageCompression = TIFFEncoding.TIFFLZW; // 设置LZW压缩
for (; i < fA.length; i += 5){
process (fA[i]);
}
@moluapple
moluapple / GradientMagic_Sg.js
Created October 25, 2011 03:03
AI 渐变巫术师 Scriptographer 版
script.coordinateSystem = "bottom-up";
var values = {
type: '径向',
opacity: !1,
center: !0,
count: 2,
random: !0,
colormode: '随机',
start: 60,
end: 120,
@moluapple
moluapple / gist:1200769
Created September 7, 2011 14:50
[Illustrator, Scriptographer] Arrange Objects On Path
// yet another Scriptographer script
var oPath = document.selectedItems[0],
// u = oPath.reverse(),
len = oPath.length,
segments = oPath.segments,
parts = 20,
i = 0;
for (; i <= parts; i++) {
var point = oPath.getLocation(len / parts * i).point,
@moluapple
moluapple / gist:1200180
Created September 7, 2011 09:50
[Illustrator, Scriptographer] Remove Unnecessary PathPoints
// This is a Scriptographer script
document.getItems({
type: Path,
hidden: false
}).each(function (path){
var curves = path.curves, i = curves.length - 1, curve, curvePre;
for (; i > 0; i--){
curve = curves[i];
curvePre = curve.previous;
curve.isLinear() && curvePre.isLinear() &&
@moluapple
moluapple / gist:1167366
Created August 24, 2011 05:29
[ESTK] windows_environment_variables
var environVar = ["ALLUSERSPROFILE", "PROGRAMDATA", "APPDATA", "COMPUTERNAME", "COMMONPROGRAMFILES", "COMMONPROGRAMFILES(x86)", "COMSPEC", "HOMEDRIVE", "HOMEPATH", "LOCALAPPDATA", "LOGONSERVER", "PATH", "PATHEXT", "PROGRAMFILES", "PROGRAMFILES(X86)", "PROMPT", "SystemDrive", "SystemRoot", "TEMP", "USERDOMAIN", "USERNAME", "USERPROFILE", "WINDIR", "PUBLIC", "PROGRAMDATA", "PSModulePath", "PROCESSOR_ARCHITECTURE", "PROCESSOR_ARCHITEW6432"],
i = 0, len = environVar.length;
for (; i< len; i++){
$.writeln(environVar[i] + ': ' + $.getenv(environVar[i]));
}
@moluapple
moluapple / AI_deleteUnusedSwatches.jsx
Created August 22, 2011 13:33
[Illustrator] Delete Unused Swatches
//only for mark. For work, use John Wundes's script please.
//http://www.wundes.com/JS4AI/delete_fluff.js
function deleteUnusedSwatches (doc) {
var items = doc.pageItems,
len = items.length,
sw = doc.swatches,
slen = sw.length,
arr = [],
str = null,
@moluapple
moluapple / gist:1148519
Last active April 8, 2025 13:50
[Photoshop] Text Contents Collector
(function () {
function layersText(oDoc) {
var oLayers = oDoc.layers, text = [], i, j, file;
function getTextLayers(oLayers, i) {
for (i = 0; i < oLayers.length; i++) {
oLayers[i].layers ? getTextLayers(oLayers[i].layers, j) : oLayers[i].kind == LayerKind.TEXT && text.push(oLayers[i].textItem.contents);
}
}
getTextLayers(oLayers, i);
file = new File(String(oDoc.fullName).replace(/(psd|tiff?)$/i, 'txt'));