How does one force an image to a defined color palette?

I'm trying to limit the colors displayed in an RGB image but I'm not sure how to go about doing. I have a palette of 454 colors (so indexed color is not an option) and I would like to force my image to that color space. This may seem like an odd request, but there's actually a (theoretically) logical reason for it: in a nutshell, I have a swatch palette that corresponds to colors of a particular brand of thread and I want to fit the image's colors to the nearest thread color. While I might be able to do that by eye, I have 454 choices to choose from (laborious!) and I'd prefer to automate the process by letting Photoshop's adaptive color conversion algorithms do their magic.
Or am I overlooking something obvious?
I appreciate any suggestions or assistance!

Charles,
I went ahead and cobbled together a script from other's code to generate a directory full of 100x100 72dpi jpg swatches from a CSV list of names, R, G, and B values. I fed the 454-file directory to MacOSaix and I'm letting it do it's thing. Thanks for the suggestion!
I doubt it will be of any value to anyone, but here's the script, just in case:
#target Photoshop
function main() {
     if (isOSX()) {
          var csvFile = File.openDialog('Select a CSV File', function (f) { return (f instanceof Folder) || f.name.match(/\.csv$/i);} );
     } else {
          var csvFile = File.openDialog('Select a CSV File','comma-separated-values(*.csv):*.csv;');
     if (csvFile != null) {
          fileArray = readInCSV(csvFile);
          var columns = fileArray[0].length;
          //alert('CSV file has ' + columns + ' columns…');
          var rows = fileArray.length;
          //alert('CSV file has ' + rows + ' rows…');
          if (columns == 4 && rows > 0) {
               generateSwatches(csvFile);
          } else {
               var mess = 'Incorrect CSV File?';
               isOSX ? saySomething(mess) : alert(mess);
     } else {
          var mess = 'Ooops!!!';
          isOSX ? saySomething(mess) : alert(mess);
main();
function generateSwatches(csvFile,directory) {
     var docRef = app.documents.add();
     with (docRef) {    
//         for (var i = unusedSwatches.length-1; i >= 0; i--) {
//              unusedSwatches[i].remove();
           var directory=csvFile.path;
          for (var a = 0; a < fileArray.length; a++) {
               var filename = fileArray[a][0] +".jpg"; // First Column is name for file                     
               r = parseFloat(fileArray[a][1]); // Second Column is Red
               g = parseFloat(fileArray[a][2]); // Third Column is Green
               b = parseFloat(fileArray[a][3]); // Forth Column is Blue
               if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) {
                    SaveJPEG(filename, directory, r, g, b);
               } else {
                    var mess = 'Color values are out of range?';
                    isOSX ? saySomething(mess) : alert(mess);
function readInCSV(fileObj) {
     var fileArray = new Array();
     fileObj.open('r');
     fileObj.seek(0, 0);
     while(!fileObj.eof) {
          var thisLine = fileObj.readln();
          var csvArray = thisLine.split(',');
          fileArray.push(csvArray);
     fileObj.close();
     return fileArray;
function saySomething(stringObj) {
     var speakThis = 'say "' + stringObj + '" using "Fred"';
     app.doScript(speakThis, 1095978087); // AppleScript
function isOSX() {
  return $.os.match(/Macintosh/i);
function SaveJPEG(filename, directory, r, g, b){
      // create doc
   app.preferences.rulerUnits = Units.PIXELS
   var doc = app.documents.add(100, 100, 72, filename,);
    // define your fill color
   var color = new SolidColor();
   color.rgb.red = r;
   color.rgb.green = g;
   color.rgb.blue = b;
   var imagefile = new File(directory+"/"+filename);
   jpgSaveOptions = new JPEGSaveOptions();
   jpgSaveOptions.embedColorProfile = true;
   jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
   jpgSaveOptions.matte = MatteType.NONE;
   jpgSaveOptions.quality = 12; //JPEG quailty (1-12)
      // fill layer
   doc.selection.selectAll();
   doc.selection.fill(color);
    activeDocument.saveAs(imagefile, jpgSaveOptions, true ,Extension.LOWERCASE);
   // close document
   doc.close(SaveOptions.DONOTSAVECHANGES);
(Is this overkill and wildly unnecessary? Of course it is.)

Similar Messages

  • In the new Pages, how does one send an image to the background (and make it selectable)?

    How does one send an image to the background in the new Pages and how does one make it selectable?

    Also why don't TEXT to Speech short cuts established in system preferences work in the new Pages?
    I am confused (and not completely happy)

  • How does one access their images in their libraries in Desktop Adobe Photoshop that are connected to their Mobile Adobe Shape?

    So
    I have Adobe Shape on my iphone, and in my Creative Cloud on the web it can access the images ive made. BUT, these images wont show up in my library on Photoshop on my computer and i cant seem to save them from the creative cloud on the web.
    How does one get from A to B?
    Thankyou
    Victoria

    Hi Victoria and welcome to the forum.
    I had to Google Shape but it looks interesting, and dies use the CC Libraries.  I am a big fan of CC Libraries, but have only used them between apps on the same machine.  So it is just a matter of see how they work between different systems
    Illustrator Help | Creative Cloud libraries - collaborate, sync, and share assets
    In my experience, I simply drag an asset onto the Library in one app, and it is there in my other apps.  But I have to make sure I am looking at the same library name on both computers.  Now I have been confused over syncing before, but I suspect that if you open the Application Manager and click on the little Cog icon, and in the Files tab make sure Sync is checked.  Otherwise you might as well read the help files.
    Sync digital assets in Adobe files and apps | Creative Cloud Libraries
    Good luck

  • How does one force Application Manager to do a re-install?

    I uninstalled Acrobat X to try and resolve some issues with plugins, but Adobe Application Manager insists it's already installed and won't let me download or attempt to re-install it again..
    Can one force a re-install of an already installed application?  Or at least persaude AAM to re-evaluate what is and what isn't installed?  After all, I used it to install these apps - it should have some idea of what's what..

    http://helpx.adobe.com/creative-cloud/kb/cant-install-acrobat-aam.html
    .. did resolve my situation (there are occasions when my brain just melts and I can't digest what the heck I'm reading.  Sigh.  Apologies for wasted bandwidth.

  • How does one attach an image to a domain in mail?

    I understand how to attach a picture, or image, to a specific person in Apple's mail.  For example, I can attach a picture of, say, the Apple logo to the email addressed [email protected]
    However, it would be really useful if I could add a Apple logo to everyone from Apple that emails me (the entire domain).  In other words, I don't just want to attach an Apple logo (to use this example) to [email protected], but instead want to attach a picture, or image, to every email address ending in apple.com
    Does any know if this is possible? 

    I understand how to attach a picture, or image, to a specific person in Apple's mail.  For example, I can attach a picture of, say, the Apple logo to the email addressed [email protected]
    However, it would be really useful if I could add a Apple logo to everyone from Apple that emails me (the entire domain).  In other words, I don't just want to attach an Apple logo (to use this example) to [email protected], but instead want to attach a picture, or image, to every email address ending in apple.com
    Does any know if this is possible? 

  • If Adobe has disabled the ability to use Lightroom 5.7 to view the images in the external harddrive, how does one view the images in the file on the external drive without bringing them back to the Lightroom Library?

    Jpeg images dragged over from Photoshop are veiwable as thumbnails on the external harddrive.  However images brought over as RAW of DNG are not viewable.  Is there anyway to view these type images on the external harddrive?  It would be nice to have a glimpse of what you are bringing into Lightroom by just looking on the external harddrive as you can with the jpegs.

    From the Library simply click the import button and navigate to your folder on the ehd. Choose the folder and click Add at the top of the dialog. You should see thumbnail previews in the import dialog where you can select what to import.

  • How does one pan an image with Preview??

    There doesn't seem to be a hand tool in order to pan a zoomed image.  Help would be appreciated.

    On my magic mouse I can just swipe (up, down, left or right) with my finger. The arrow keys seem to work for me too.
    What kind of pointing device do you have (trackpad, magic mouse, apple mouse, etc.)?
    Edit: If you have a mouse with a standard scroll wheel try holding the shift key to scroll horizontally.

  • How does one capture an image of a selected area of a window ?

    I tried the "System Preferences" "Keyboard Mouse" "Keyboard Shortcut" and the combination of keys decribed there- but they do not work.
    Better to say, they work sometimes and don't on others. What can be the clue?
    Can somebody advice me?
    Additionally: an option is given to save the picture as a file. This has never worked. Or if it works, I don't know where the saved files are stored.
    MacBook 1.1   Mac OS X (10.4.8)  

    try using the (shift key) the (apple key) and
    the(4
    key) at the same time. Then, you will get a "Cross
    Hairs" just move it a round
    ... and when the crosshair appears, hit the spacebar
    and see what happens
    MacBook C2D 2.0Ghz - 4H647
    Mac OS X (10.4.8) 2GB RAM
    Hey great! It seems there are always more and more keyboard tricks.

  • How does one reduce the size of a photo on iphoto?  I want to post images on my website, but they exceed the limit.

    How does one reduce the size of a photo on iphoto.  I want to post images to my website but they exceed the limits. 

    Select the photo(s) and export (file menu ==> export) them. You can change the size there setting a maximum pixel dimension and/or reducing quality
    LN

  • How does one crop an .ai image to a defined shape?

    How does one crop an .ai image to a defined shape?
    In other words, I want to select and crop from a larger image an area such as a rectangle that I define.
    Right now, I try to select and crop a rectangular portion of an image but every shape that is even partially within the rectangle is selected both within and without the rectangle.
    I am using CS2 on a Mac.

    Clifford,
    I've figured out part 1, how to crop an image using a rectangle on  another layer.
    Then I did:
    To really get rid of the outlying parts, with the Clipping Mask still 
    selected you may:
    5) Choose anything but Normal in the Transparency palette dropdown 
    and Object>Flatten Transparency (just keep the defaults).
    The result was "Filter cannot complete because of unknown error"  FSpt
    Is this a bug, or is their a problem with the way I am following your 
    method?
    It is hard to say.
    It is more convenient to place the rectangle mentioned in 1) on the same layer; if you place the path(s) to define the Clipping Mask, the Clipping Mask and its contents will be on that layer, everything from lower layers being moved to it.
    What about 2) - 4)?
    It is easier to answer if you state what happens in the individual steps (repeated here):
    1) Create a rectangle on top of the image with the same size (you may use the Transform palette/panel to see the size, and to place it by);
    2) Create the cutout shape;
    3) Select 1) and 2) and Object>Compound Path>Make;
    4) Also select the image, and Object>Clipping Mask>Make.
    To really get rid of the outlying parts, with the Clipping Mask still selected you may:
    5) Choose anything but Normal in the Transparency palette dropdown and Object>Flatten Transparency (just keep the defaults).

  • New to using Firefox with MAC: How does one save a single jpeg image from the web (as in a right click on a pc?)

    New to using Firefox with MAC: How does one save a single jpeg from the internet, similar to using the right mouse click on a pc?

    If your question comes about because you have a single button mouse, it's time to visit your local computer store and get a ''real'' mouse for that MAC. I don't "get" Apple, they sell their hardware for almost twice what a comparable PC would sell for - and then they leave out what is probably the most important time saving control, the right-button.
    See this for setting the hidden pref for context menus in Firefox, for Mac's.
    http://kb.mozillazine.org/Ui.click_hold_context_menus
    type '''about:config''' in the URL bar and hit Enter
    Pref Name = '''ui.click_hold_context_menus'''
    Double-click to Toggle to '''True'''

  • I have a MacAir, mid 2011 model, and want to view video on my TV.  I see that I need a mini display port to Hdmi but there are many of these.  What exatly do I need and how does one view a movie downloaded to the MacAir on a TV screen?

    I have a MacAir, mid 2011 model, and want to view video on my TV.  I see that I need a mini display port to Hdmi but there are many of these.  What exatly do I need and how does one go about viewing a movie downloaded to the MacAir on a TV screen?

    Welcome to Apple Support Communities
    That's exactly what you need. A Mini DisplayPort to HDMI adapter and a HDMI cable. See > http://support.apple.com/kb/HT4241?viewlocale=en_US
    This is the only way to view a video on the TV. After connecting your MacBook Air to the TV, image on your TV should show immediately. Then, press Command and F1 keys to mirror your MacBook Air display, and open the video

  • How Does One Modify Photoshop Templates in Dreamweaver

    I posted this over on the Photoshop forum, but no one has
    replied. It is a hybrid sort of question.
    I've been trying to modify the Horizontal Neutral template of
    the Web Photo Gallery in Photoshop CS using Dreamweaver MX (v.6.1)
    on my G5 running Tiger and am almost there. Aside from the overall
    design (fonts and colors) I really like the interface of this
    particular gallery with a horizontal slider to quickly scroll
    through images, that when selected, appear in large form in the
    center of the page. But I need to customize it to get it to match
    the feel of my site.
    My problem: I'm trying to point to a gif file that is part of
    my website image library as my background. I want the Horizontal
    Neutral Gallery to float in that image background. But, I can't
    seem to get the background image to appear where it is supposed to.
    I've gone into the various components of the template
    (FrameSet, SubPage, etc.) and by duplicating the files and
    modifying the code, I am able to get the background image to appear
    within the tables that make up the navigation and image gallery
    components. But, I've not been able to get the image to appear as
    the background itself.
    I'd even be happy to simply have the entire Horizontal
    Neutral Gallery float in the middle of one of my own pages with the
    image file as a background if it is possible, but can't seem to
    even get it to do that. How does one access the code that controls
    the background image in this template or the script that generates
    these galleries?
    Thanks in advance!

    The reason the that the edit button ( - ) top righthand corner had 'disappeared', was that iCloud was enabled but that the Addressbook subsetting under iCloud was set to off in the phone settings.
    Changing it to 'on' made the edit button reappear.
    Thanks to the guys in Cambridge Apple Store!!
    The reason the that the edit button ( - ) top righthand corner had 'disappeared', was that iCloud was enabled but that the Addressbook subsetting under iCloud was set to off in the phone settings.Changing it to 'on' made the edit button reappear.
    Thanks to the guys in Cambridge Apple Store!!

  • How does one transfer CS5 actions for use with CS6?

    CS6 installation, which was uneventful, has transferred none of my actions from my copy of CS5. The CS5 actions are located in the actions folder of the APPLICATION/PHOTOSHOP CS5/PRESETS/ACTIONS.  The "actions" folder in application support/adobe in my library is empty, and has always been so.
    Only the CS6 default actions are located in the same folder for CS6.
    I use imac i7, lion.
    Note that i also have CS3 and CS4 on my machine. This due to recent upgrade to CS5 and recent upgrade to LION, and my general paranoia.
    Must i load each action into CS6, one at a time?
    thanks to any and all.
    vince

    Re: how does one transfer CS5 actions for use with CS6?
    On a Mac - There are multiple ways to do this.  I have done them both ways. In order to do this you need to know where you have your actions stored, and you can move them all at once if you have them stored in the same location.
    1. You can load an action ONE AT TIME into your actions palette by:
         A. Open up the action palette and click on the little arrow with 4 little horizontal lines next to it on the upper right corner of the actions palette.
         B. Select "Load Actions" and a Finder window will open up and you can search your computer through this window for your actions.
         C. Click on the action from the Finder window then click 'Open' at the bottom right of the finder window.
         D. To save these so that they appear every time you open up your actions palette, go back to the little arrow at the top right of the actions palette and when the drop down window opens- click on 'Save Actions'. It will select the location where the          actions are currently stored as the place to save them. If you want to change that path, you can do it at this time in the little path window.  I just leave it, since I keep all my actions stored in the same file.
    2. TO MOVE MULTIPLE ACTION SETS AT ONCE
         A. Open up CS6 (or CS5) and move the Photoshop workspace it to the right side of your computer screen so you can see your desktop on the left side.
         B. Open up your Finder search window from your dock (the square blue head icon thingy for those who are new to photoshop). Move this to the left side of your screen so you can see the Photoshop work space on the right and the Finder window          on the left. In the Finder window, navigate to the file where all your actions are stored, select all the actions in the file (command+A will select everything in the file if you are actively inside the open file) or you can select multiple files           individually by continuously holding down the command key and clicking on the different actions you want to move.
         C. With the Photoshop workspace visible on the right, and the actions palette open so you can see that the actions actually transferred - In the Finder window, click the selected actions you want to load and drag them over to the Photoshop           workspace.  I did this without an image open, I just dragged them onto the empty workspace.  The actions should all appear immediately in the actions palette that is open.
         D. To save these so that they appear every time you open up your actions palette, go back to the little arrow at the top right of the actions palette and when the drop down window opens click on 'Save Actions'. It will select the location where the           actions are stored as the place to save them. If you want to change that path, you can do it at this time in the little path window.  I just leave it, since I keep all my actions stored in the same file.
    I hope this helps. 
    and I hope there are no typos. 

  • How does one manage these new render setting for previews?

    I placed 4 HD clips from a nested into a sequence 5800 x 768 to mimic 4 side by side monitors for a multi channel video.  Each clip cut from the sequence are at 1280x720 all sitting side by side. However when I rendered the previews, they came look all squished. However when I exported the frame it looks fine in Photoshop. (I changed the uploaded image to what it looks like in Premiere in Photoshop to demonstrate the appearance in Premiere.)
    I imagine that the distortion has to do with the sequence render setting which for some reason comes out to 1918 x 253...or the pixel aspect ratio? How does one manage these new render setting for previews so it looks normal in the monitor? 
      

    Either way, I thought that this format would be a great way to view on the monitor 4 channels at the same time. I may need to place them on a “normal” 1440 x 1080 sequence in a line, bringing them down to 25% scale to make it work in the end. I did just try that. I think it will work...but when I imported and nested the old file, the scratch disks changed from the original set up on a D drive back to the main hard drive so I had to change it agin. Otherwise it works fine...so I’ll go with this for now
    These are the instructions I was given.I attched a screen save of the AE file they asked me to use (They must be on vacation, because I have not been able to get hold of them). I don't know After Effects very well:
    “As you begin creating or adapting work for e4c, you may find an After Effects template developed for this system to be helpful. Attached you'll see a zipped file with two AE templates. There is some detailed information (below) from the artist that developed these for us. In addition, a few bits of information that might help you along are:
    ·        The "Watchout"  playback system can support WMV or a QuickTime files . We like .mov files with H.264 codec best!
    ·        The end resolution of the four screens is 5120 x 720 pixels (1280x720 each).
    ·        If works are four-channel, please provide a separate audio (aiff) file so it doesn't slow any one video down.”
    Thanks for your help!

Maybe you are looking for