Selecting pixels in a picture and changing their color with a script

Hi, I'm brand new to photoshop scripting, and I want to make a script that takes every pixel of a color and replaces it with a new color,
I'm having the hardest time finding any information on the internet on how to do it though.
I do have some background in other coding, so the concepts are not new, just the language and functions.
I know there's tools and filters already, but I want to make a script so I can add features.
Any help would be appreciated.
Thank you!
(P.S. Is there a way to open and read code of a pre-exsisting filter, or is that impossible?)

To create your own filters you would need to download the SDK I think you might find an example of a filter.
With Photoshop this might be close...
main();
function main(){
if(!documents.length) return;
var sColour =new SolidColor;
sColour.rgb.hexValue ='245887';
selectColorRange(0,sColour);
try{
var SB = activeDocument.selection.bounds;
    }catch(e){return;}
var FillColour =new SolidColor;
FillColour.rgb.hexValue = 'ff0000';
activeDocument.selection.fill(FillColour,ColorBlendMode.NORMAL);
activeDocument.selection.deselect();
function selectColorRange( fuzz, solidColor){
var scaleA = (solidColor.lab.a + 128.5) / 256;
    var desc11 = new ActionDescriptor();
    desc11.putInteger( charIDToTypeID( "Fzns" ), fuzz );
        var desc12 = new ActionDescriptor();
        desc12.putDouble( charIDToTypeID( "Lmnc" ), solidColor.lab.l );
        desc12.putDouble( charIDToTypeID( "A   " ), solidColor.lab.a + scaleA);
        desc12.putDouble( charIDToTypeID( "B   " ), solidColor.lab.b + scaleA);
    desc11.putObject( charIDToTypeID( "Mnm " ), charIDToTypeID( "LbCl"), desc12 );
    desc11.putObject( charIDToTypeID( "Mxm " ), charIDToTypeID( "LbCl" ), desc12 );
executeAction( charIDToTypeID( "ClrR" ), desc11, DialogModes.NO );
Using Christophs suggestion...
//Use 1 pixel to colour
app.activeDocument.colorSamplers.removeAll();
var mySampler = app.activeDocument.colorSamplers.add([new UnitValue(1,'px'),new UnitValue(1,'px' )]);
//Get original colour
var oColour = new SolidColor();
oColour = mySampler.color;
app.activeDocument.colorSamplers.removeAll();
//Select colour
var sColour = new SolidColor();
sColour.rgb.hexValue ='31618f';
activeDocument.selection.select([[0,0],[1,0],[1,1],[0,1]], SelectionType.REPLACE, 0, false);
activeDocument.selection.fill(sColour,ColorBlendMode.NORMAL);
//Replacement Colour
var rColour = new SolidColor();
rColour.rgb.hexValue ='ff0000';
activeDocument.selection.similar(0, false);
activeDocument.selection.fill(rColour,ColorBlendMode.NORMAL);
activeDocument.selection.deselect();
//Replace original colour.
activeDocument.selection.select([[0,0],[1,0],[1,1],[0,1]], SelectionType.REPLACE, 0, false);
activeDocument.selection.fill(oColour,ColorBlendMode.NORMAL);
activeDocument.selection.deselect();

Similar Messages

  • TS4436 How do I select more than one picture and send them all to Facebook on my iPhone 4s with iso7?

    How do I select more than one picture and send them all to Facebook on my iPhone 4s with iso7?

    Hi, I want to thank you for all your information regarding my questions about sending more than one photo to Facebook. I did have to stop in at Verizon (where I bought my iPhone) to find out why I did not have a choice to choose Facebook with the export icon. The tech had to go into my setting and enable Facebook to recognize my iPhone. When I upgraded to iso7 somehow it could not recognize Facebook. Once he did this for me I was able to follow your advice and your answer solved my question. Thank you

  • I have been informed by Orange (UK) that Apple have 'changed their rules' with regards to unlocking iPhones, and that it will take 6 months to process. Is this correct?

    I have been informed by Orange (UK) that Apple have 'changed their rules' with regards to unlocking iPhones, and that it will take 6 months to process. Is this correct?

    Fezzzer wrote:
    I have been informed by Orange (UK) that Apple have 'changed their rules' with regards to unlocking iPhones, and that it will take 6 months to process. Is this correct?
    Complete rubbish
    Apple do not lock iPhones
    Carriers do because they have subsidised the purchase price
    and therefore only the carrier can unlock an iPhone
    Orange have decided to apply 6 months to protect their revenue
    they never have been the fastest to unlock

  • Dante font used in manuscript - when I try to save as a pdf document in Microsoft Word whole pages change their look, with wide gaps forming between certain paragraphs or sections. This does not happen with other fonts.

    Dante font used in manuscript … when I try to save as a pdf document in Microsoft Word whole pages change their look, with wide gaps forming between certain paragraphs or sections. This does not happen with other fonts.

    OK, we've got it!
    What is happening is that when you use Microsoft's save as PDF in Word, the font isn't embedded even though the font is tagged to allow embedding. Furthermore, Microsoft doesn't properly put the font name into the PDF file such that Acrobat or Reader can readily find the font installed on your system such that the text can be properly displayed and/or printed. Acrobat and Reader attempt to display and/or print the text using a “substitution font” and of course, as they say, YMMV (“your mileage may vary”)!
    I personally submitted the report of this problem (both the embedding and the font name problem) to Microsoft. They acknowledge the bug, tried a fix and provided me a build with it, but it wasn't right. Maybe they will ultimately fix it, maybe they won't. We don't know yet. We do know that if it is fixed, it will be fixed only for Office 2013 (problem occurs with all Office applications since they use the same PDF generation code) and thus such a fix won't help you.
    Adobe Acrobat Standard and Acrobat Pro  both provide an Adobe PDFMaker plug-in to Office applications (including full support for Office 2010) that adds an Acrobat Toolbar as well as a Save as Adobe PDF menu item. The resultant PDF file fully supports embedding of OpenType CFF, TrueType, and Type 1 fonts and in many other ways produces much superior PDF with a full range of PDF generation options not available with the Microsoft PDF. (Note that beginning with Office 2013, Microsoft does not support Type 1 fonts in Office documents at all, even for existing documents!) The Acrobat Office functions are widely used and respected in the end user community and whatever “issues” there are (all software has “issues” of some type - it is a matter of how many and how severe), you should be in much better shape for PDF production that with what you currently are using.
    Good luck and let us know if this resolves your problems. (Note that you can download and install a free fully-functional 30 trial of Acrobat Pro to assure that it meets your needs! You can then buy a license and activate what you already have installed.)
              - Dov

  • Why do drop shadows created in Illustrator CC randomly change their color mix?

    Drop shadows that I've created in Illustrator CC will randomly change their color mix when they are different mixtures of cmyk black, usually after closing and opening again. For example, if the drop shadow is 75c 68m 67y 90k, the next time I open the file it will 20c 0m 0y 100k. This happens with many of my files, and has been going on for several months. Thanks.

    Hey I found out from the developers that this is actually fixed in version 29 via Bug 965861. Try the pdf viewer in the next version of Firefox, this will take care of that gradient. :-) Cheers.

  • How to make a selection of a layer delete content and paste another content with Photoshop scripting..?

    how to make a selection of a layer delete content and paste another content with Photoshop scripting..?

    There is a more specific Forum …
    Photoshop Scripting

  • How to remove and change the color of Java cup and border

    Hi to all,
    How to remove and change the color of Java cup and border.
    Thanks in advance
    khiz_eng

    This is just an Image. You would need to create your own image and call setIconImage(Image) on your JFrame.

  • Can I cycle through and change the color overlay of certain layers by name using script?

    Can I cycle through and change the color overlay of certain layers by name using script?

    Sure. Ask in the scripting forum and refer to the scripting docs.
    Mylenium

  • I have to select a file – get Info – and change – open with and change from preview to another program and CHANGE ALL everytime I boot up

    Why do I have to select a file – get Info – select – open with – and change from Preview to another program and click CHANGE ALL with every file extention everytime I boot up.

    Back up all data.
    This procedure will unlock all your user files (not system files) and reset their ownership and access-control lists to the default. If you've set special values for those attributes on any of your files, they will be reverted. In that case, either stop here, or be prepared to recreate the settings if necessary. Do so only after verifying that those settings didn't cause the problem. If none of this is meaningful to you, you don't need to worry about it.
    Step 1
    If you have more than one user account, and the one in question is not an administrator account, then temporarily promote it to administrator status in the Users & Groups preference pane. To do that, unlock the preference pane using the credentials of an administrator, check the box marked Allow user to administer this computer, then reboot. You can demote the problem account back to standard status when this step has been completed.
    Triple-click the following line to select it. Copy the selected text to the Clipboard (command-C):
    { sudo chflags -R nouchg,nouappnd ~ $TMPDIR.. ; sudo chown -Rh $UID:staff ~ $_ ; sudo chmod -R u+rwX ~ $_ ; chmod -R -N ~ $_ ; } 2> /dev/null
    Launch the Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid.
    Paste into the Terminal window (command-V). You'll be prompted for your login password, which won't be displayed when you type it. You may get a one-time warning not to screw up. If you don’t have a login password, you’ll need to set one before you can run the command. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator.
    The command will take a noticeable amount of time to run. Wait for a new line ending in a dollar sign (“$”) to appear, then quit Terminal.
    Step 2 (optional)
    The first step should give you usable permissions in your home folder. This step will restore special attributes set by OS X on some user folders to protect them from unintended deletion or renaming. You can skip this step if you don't consider that protection to be necessary.
    Boot into Recovery by holding down the key combination command-R at startup. Release the keys when you see a gray screen with a spinning dial.
    When the OS X Utilities screen appears, select
    Utilities ▹ Terminal
    from the menu bar. A Terminal window will open.
    In the Terminal window, type this:
    resetpassword
    That's one word, all lower case, with no spaces. Then press return. A Reset Password window will open. You’re not  going to reset a password.
    Select your boot volume ("Macintosh HD," unless you gave it a different name) if not already selected.
    Select your username from the menu labeled Select the user account if not already selected.
    Under Reset Home Directory Permissions and ACLs, click the Reset button.
    Select
     ▹ Restart
    from the menu bar.

  • How to drag and drop item from list to another item in list and change their positions

    I have a list field with multiple items. I want to select one item from list and drag and drop to another item in the list
     after drop item on another item the position of items should be change. (Example:- if I select 1st item from list and drag and drop this item to 4th item in list after drop that item position of both item should be changed 1st item on 4th position and 4th item on 1st position)
    I don't know how to do this.Please help me to find the solution.

    Hello Zoltan,
    I do not believe that kind of option is built into the listboxes, but I was able to have similiar functionalities using property nodes. I have included an example program that I put together.
    The big difference is that instead of dragging, you double click on the item you want to transfer. To highlight items as you go down the list, all you need to do is set the value to that list number.
    Hope this helps you out!
    Attachments:
    Temp.vi ‏33 KB

  • Can i select displays mirror and change audio output with applescript

    Hi
    I am trying to write an Applescript the will gather and mirror displays and change the audio out setings. Can this be done?

    Hi Keith,
    you can handle the channels like "normal" strings. See the attached picture.
    Hope it helps.
    Mike
    Message Edited by MikeS81 on 07-25-2008 06:46 AM
    Attachments:
    Unbenannt1.PNG ‏6 KB

  • I am unable to select any title or picture and drag it to the timeline

    I was working with this proyect normally and suddenly it stopped me from doing it. Please help!!!
    I have the little hand as the cursor, I do not know if that might be teh problem.

    iMovie'11 on a mac.... The project is not long at all... just 4 minutes long, only pictures and titles, no videos included. It is very strange, I tried to reset as you said, and it worked perfectly afterwards, now it is doing it again and again, it gets frozen and then I cannot drag the titles or pictures into the timeline above. It is doing weird stuff .... for example, I am working normally in the project and then I add a title, when I play the project the title that I placed appears over a picture... or sometimes it appears completely black. I know I am not adding the title over the picture....so do you think there is something wrong with the app itself?
    Thanks for your help.

  • Is there a "live" selection that will deselect as you change the color?

    As a textile designer I use Index mode a lot to reduce down to a certain number of colors and then I usually have to go in and clean it up.
    A lot of times I select a certain color and then selectively go in and change it to a different color in the print. Usually they are stray pixels.
    I don't want to change all the instances of the colors just in specific places.
    My colleague swears that the first couple of days she was working in CC the marching ants would go away as she changed colors. But she has no idea why it stopped or how it happened in the first place.
    Is this a possibility??
    It would make my life so much easier if I could see my progress in real time.

    Create a variable for the title and use it in both places.
    <?php
    $title = 'Things you always wanted to know about...';
    ?>
    <title><?php echo $title; ?></title>
    // later on
    <?php echo $title; ?>
    Alternatively, if your page content is generated dynamically, you can store the title in the database.
    Another technique would be to base the title on the page name.
    $page = basename($_SERVER['SCRIPT_FILENAME'], '.php');
    $title = ucwords(str_replace('_', ' ', $page));
    That would store "About Us" in $title if the page is called about_us.php.

  • Where are my pictures and what's wrong with iPhoto??

    Hello Apple Support Community!
    Since I have updated iPhoto a few weeks ago, it didn't work right anymore.
    Everytime I started it, I had to repair the whole libary.
    Because I was tired of waiting several hours I didn't use it until now.
    Today I wanted to update my pictures and sync it with my iPhone but iPhoto tells
    me that it may be used by another programm (I don't think so) or can't be read anymore.
    I looked up the iPhoto libary and opend it to see if my pics are still there (Information tells me
    that the size is about 25GB) but there is no folder called "originals" and there isn't a single picture in it!!
    I have no copies of the pictures and I would be very sad if they were lost...
    I'm looking foward to receive your support and your ideas!
    Sincerely,
    Lukas

    we actually need details to help
    - all taps are grey, so I can't open "about iPhoto" but the app store tells me that iPhoto 9.5.1 is installed
    No place did I suggest opening "about iPhoto"  what I ask you to do was
    look in the Applications folder and select the iPhoto application - get info - what version so you have on your computer?
    Looking in the App store is not useful - we know that you have a problem and one possibility is that the App store is confused about what you have so you need to provide the requested information following the directions given
    and I have no idea in the wrold what you have done or have - first you say that when you try to rebuild the iPhoto library you get
    Ad 3) I already tried to do it but the programm tells me that it will start when a libary is available because there is a time machine backup running (I never activated time machine)
    Then you say
    - done, but nothing new happened
    What does that mean - immediately after restarting when you
    Back up your iPhoto library, Depress and hold the option (alt) and command keys and launch iPhoto - rebuild your database
    what exactly does happen? Are you saying that you get the message that TM is backing up? Or are you saying that the rebuild does not help? Or are you saying something else?
    Remember we can not see you or your computer and to help you you need to follow instructions and provide revenant detailed accurate reports to us
    - i found a lot of pictures of the face recognition service of iPhoto!
    Source:
    /Users/lukasschroll/Pictures/Bibliothek iPhoto/Thumbnails/2012/12/07/20121207-223417
    Again you are mucking around inside the iPhoto library - I strongly suggest tha tyou STOP doing this
    again it is critical that you stop doing this as I previously said
    4 - Stay out of the iPhoto library unless specifically directed by an expert to do things in it - there are no user servicable parts in it and it is extremely easy to make a mistake and deestroy it and lose data
    LN

  • Every time I try to replace text on a brochure template, the colors inexplicably change- and when I try and change the color, it doesn't let me- help, very frustrated:)  Please respond in laymen's terms:P

    Hello Everyone,
    I am working with the Green Grocery Newsletter Template, and I am trying to substitute the text.  As an example of my issue, when I highlight the title text and start typing, it turns blue, even though the text color box still shows green.  Actually, any text I try to replace turns blue!  If I try to change the color of my blue text, the text color box shows the new color, but the text on the template is of course, still blue.
    Please help:)! So frustrated and on a deadline.
    Thank you:)!
    Kindra

    Just wondering, when you pull up the inspector, is the writing that is coming up blue a hyperlink (when you click on it, will it take you to a web page or an e-mail)?

Maybe you are looking for

  • Can't install Bootcamp, stuck in Windows XP

    Hey everybody, I recently got a MacBook Pro with OS X Lion. I partitioned the hard drive and successfully installed Windows XP. I tried to install Bootcamp, but I get an error message saying that Bootcamp can only be installed in Windows 7. How can I

  • New Buddies not appearing in list

    Starting a new thread for this problem I have.. I have this problem with the 3 new people I have added over the past 2 days. When I add them, their name comes up briefly but "flashes/fades in and out" and then disappears all together from my Buddy li

  • Synchronize file time stamp problems

    I upload files from Dreamweaver (CS3) to the server. The time stamp on the local files will say 3:37 p.m., but the time stamp on the remote server will say 7:44 p.m. Also, when I select synchronize, it will tell me that some of the files on the serve

  • How to install PSCS6 on a new computer?

    Viens d'acheter un nouvel ordinateur. Comment installer Photoshop CS6 sur celui-là? J'ai les numéros de série.

  • Fonts artefacts with lxdm

    Chromium menu: This artefacts everywhere, in each application, as I can see. With gdm fonts rendered well. Any ideas?