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
// reference: http://www.hardcode.nl/subcategory_1/article_317-array-shuffle-function | |
Array.prototype.shuffle = function() { | |
var len = this.length; | |
var i = len; | |
while (i--) { | |
var p = parseInt(Math.random()*len); | |
var t = this[i]; | |
this[i] = this[p]; | |
this[p] = t; | |
} |
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
function Cs4SFW(FileName,Quality,MetaData, Profile,Progressive) { | |
function cTID(s) { return app.charIDToTypeID(s); }; | |
function sTID(s) { return app.stringIDToTypeID(s); }; | |
/* | |
reference -> http://forums.adobe.com/message/2582725 | |
Metadata:- | |
'MDAl' All metadata 'MDNn' No metadata | |
'MDCp' Copywright 'MDCC' Copyright and contact | |
'MDAx' All except camera info | |
Profile:- |
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
function saveForWebPNG(outputFolderStr, filename) | |
{ | |
var opts, file; | |
opts = new ExportOptionsSaveForWeb(); | |
opts.format = SaveDocumentType.PNG; | |
opts.PNG8 = false; | |
opts.quality = 100; | |
if (filename.length > 27) { | |
file = new File(outputFolderStr + "/temp.png"); | |
activeDocument.exportDocument(file, ExportType.SAVEFORWEB, opts); |
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
function save_as_file_type(fileObj) { // { fileName, fileType, path, quality } | |
if (app.documents.length == 0) { | |
alert("Please have an 'photoshop' document before running this script."); | |
return; | |
} | |
var quality = fileObj.quality || 3, //default 3 | |
path = fileObj.path || app.activeDocument.path, | |
document = fileObj.document || app.activeDocument, | |
fileName = document.name, | |
fileType = fileObj.fileType, |
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
function show_dialog(message, opened_number) { | |
// update it v 0.1.1 | |
var defaultScriptPreference = app.scriptPreferences.userInteractionLevel; | |
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL; | |
var myDialog = app.dialogs.add({name:"Continue with another file or finish?",canCancel:true}); | |
var all_messages = []; | |
with(myDialog){ | |
with(dialogColumns.add()){ | |
with(dialogRows.add()) { |
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
function get_date_string(para_date) { | |
var date = para_date || new Date(); | |
var day = (date.getDate() > 10 ) ? date.getDate() : ("0" + date.getDate() ), | |
month = ((date.getMonth()+1) > 10 ) ? (date.getMonth()+1) : ("0" + (date.getMonth()+1) ), | |
year = (date.getFullYear() > 10 ) ? date.getFullYear() : ("0" + date.getFullYear() ), | |
hours = (date.getHours() > 10 ) ? date.getHours() : ("0" + date.getHours() ), | |
minutes = (date.getMinutes() > 10 ) ? date.getMinutes() : ("0" + date.getMinutes() ); | |
return year + month + day + "_" + hours + minutes; | |
}; |
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
function combine_text_file ( files, path, new_name ) { | |
if( files.length>0 ) { | |
var all_string = ""; | |
for (var i = 0, len = files.length; i < len; i++) { | |
all_string += read_text_file( files[i] ); | |
}; | |
return write_text_file( all_string, path, new_name ); // return file | |
}; | |
}; |
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
function join_page_string (pages, symbol_first, symbol_last) { | |
var page_string = ""; | |
if( pages.length === 1 ) { return pages.toString();} | |
for (var i = 0, len = pages.length; i < len; i++) { | |
if(i < len-1) { | |
page_string += pages[i]; | |
if( i != len-2 ) { page_string += symbol_first} | |
}else { | |
page_string += (symbol_last + pages[i]); | |
}; |
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
function build_library_string(param_library_index) { | |
// v.0.1.1 no library or asset return "" | |
var library_index = param_library_index || 0 ; | |
var my_library = app.libraries[library_index]; | |
var library_assets = my_library.assets; | |
var str = ""; | |
if (app.libraries.length==0) {alert("There's no library."); return "";}; | |
if (library_assets.length==0) {alert("There's no asset in the library."); return "";}; |
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
function get_lib_index_dialog() { | |
// v 0.1.2 tested. | |
var library_name = ""; | |
var all_library_names = []; | |
var my_index = -1; | |
for (var i = 0, len = app.libraries.length; i<len;i++) { | |
all_library_names.push(remove_file_extension(app.libraries[i].name).toUpperCase()); | |
}; | |
if(all_library_names.length ===1){return 0;} | |
if(all_library_names.length>1) { |