Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > Programming Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Photoshop Script to Change Matte Color
drews
Join Date: Nov 2002
Posts: 33

 

Florida
Show Printable Version Email this Page Subscription
drews drews is offline 01-05-2007, 10:00 PM

I created a Photoshop script that will open all the PSDs in a folder and Save To Web as .gif using a matte color you specify in hex out to a folder of your choice.

You need to specify the hex color in the code around line 52, just put in the value without the preceding "#" sign. Copy and paste the code to into a new text document and save it as <somename>.jsx .

Unfortunately, it doesn't do folder traversing so if you have multiple folders it will be necessary to do each folder individually. I created this script especially for use with the vBulletin PSDs for easy matting. It has been tested in Adobe Photoshop CS2.

Code below... let me know how you like it.

HTML Code:
// enable double clicking from the Macintosh Finder or the Windows Explorer
#target photoshop

///////////////////////////
//       SET-UP          //
///////////////////////////

// A list of file extensions to skip, keep them lower case
    gFilesToSkip = Array( "db", "xmp", "thm", "txt", "doc", "md0", "tb0", "adobebridgedb", "adobebridgedbt", "bc", "bct" );

// Pops open a dialog for the user to choose the folder of documents to process
    var inputFolder = Folder.selectDialog("Select a folder of documents to process");

// Pops open a dialog for the user to set the output folder
    var outputFolder = Folder.selectDialog("Select a folder for the output files");

///////////////////////////
//         MAIN          //
///////////////////////////

// Open Folder of Images    
    var numFiles = OpenFolder();
    
///////////////////////////
//       FUNCTIONS       //
///////////////////////////

main();

function main() {
    if (app.documents.length <= 0)
    {
        alert("You must have a document open to Save For Web");
        return;
    }
    
    try
    {
        for(var i = 0; i < numFiles; i++)
        {
            //alert("Save To Web");
            RunSaveForWeb();
            //alert("Closing");
            app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
        }
    }
    catch (error)
    {
        if (error.number != 8007) // Don't report user cancelled errors.
            alert (error); //  + ":" + error.line);
    }
}

function RunSaveForWeb()
{
    //Define SaveForWeb Options
    var matteColorColor = new RGBColor();
    matteColorColor.hexValue = "000000";
    var sfwOptions = new ExportOptionsSaveForWeb();
    sfwOptions.format = SaveDocumentType.COMPUSERVEGIF;
    sfwOptions.includeProfile = false;
    sfwOptions.colors = 256;
    sfwOptions.matteColor = matteColorColor;
    sfwOptions.interlaced = 0;
       
    //Save for Web
    docPath = outputFolder;
    docName = activeDocument.name;
    var temp = new Array();
    temp = docName.split('.');
    sfwJpgFile = new File(docPath + "\\" + temp[0] + ".gif");
    activeDocument.exportDocument(sfwJpgFile, ExportType.SAVEFORWEB, sfwOptions);
}

// Given the a Folder of files, open them
function OpenFolder() 
{
    var filesOpened = 0;
    var fileList = inputFolder.getFiles();
    for (var i = 0; i < fileList.length; i++) 
    {
        // Make sure all the files in the folder are compatible with PS
        if (fileList[i] instanceof File && ! fileList[i].hidden && ! IsFileOneOfThese(fileList[i], gFilesToSkip))
        {
            open(fileList[i]);
            filesOpened++;
      }
    }
   return filesOpened;
}

// given a file name and a list of extensions
// determine if this file is in the list of extensions

function IsFileOneOfThese( inFileName, inArrayOfFileExtensions )
{
    var lastDot = inFileName.toString().lastIndexOf(".");
    if (lastDot == -1)
    {
        return false;
    }
    var strLength = inFileName.toString().length;
    var extension = inFileName.toString().substr(lastDot + 1, strLength - lastDot);
    extension = extension.toLowerCase();
    for (var i = 0; i < inArrayOfFileExtensions.length; i++ )
    {
        if ( extension == inArrayOfFileExtensions[i] )
        {
            return true;
        }
    }
    return false;
}
Reply With Quote
  #2  
Old 02-27-2007, 01:29 AM
kether1 kether1 is offline
 
Join Date: Jun 2006
Posts: 232
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What a great idea!

-Kether
Reply With Quote
  #3  
Old 06-25-2008, 10:42 PM
StepOnFrog StepOnFrog is offline
 
Join Date: Apr 2006
Location: The Pub
Posts: 58
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is exactly what I've wanted for ages.

The problem for many users is that the standard vBulletin images (buttons, smilies, status icons, etc.) are all matted to a white background (the vBulletin standard out-of-box style). When it comes to changing your style to a darker colour (black, or blue, etc.) all the images tend to show a fine white border around them, that is most off-putting.

What you have done with this article is provided users a way of keeping their standard vBulletin images (I actually prefer them to the crap that's out there...), without having to keep the standard vBulletin style (which isn't the best in the world).

The only problem users have now is getting a copy of Photoshop CS2 +.

If I could buy you a pint, I would.

Thx

:-D
step
Reply With Quote
  #4  
Old 02-04-2009, 10:45 PM
domainmagick domainmagick is offline
 
Join Date: Jan 2009
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

very nice - thanks! gonna try this out now, was just googling for this exact thing
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:52 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03791 seconds
  • Memory Usage 2,231KB
  • Queries Executed 17 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_html
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (3)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete