Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6806025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:39:34+00:00 2026-05-26T19:39:34+00:00

i want to make a little photoshop javascript. Technically, i just need to know

  • 0

i want to make a little photoshop javascript. Technically, i just need to know how to compare the color values of pixels af if they were an array with three integer values in each, for example: (pseudocode)

for all pixels x
    for all pixels y
        if left pixel's green channel is bigger than red channel:
            set the blue channel to 25
        else
            if the blue channel is greater than 50
                set the green channel to 0

in the documentation, there’s a ton of things like filters, text and layers you can do, but how do you do something as simple as this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:39:35+00:00Added an answer on May 26, 2026 at 7:39 pm

    Reading and writing pixel values in Photoshop scripts is indeed not as simple as it could be … Check out the following script which inverts the blue channel of an image:

    var doc = app.open(new File("~/Desktop/test1.bmp"));
    
    var sampler = doc.colorSamplers.add([0, 0]);
    
    for (var x = 0; x < doc.width; ++x) {
        for (var y = 0; y < doc.height; ++y) {        
    
            sampler.move([x, y]);
            var color = sampler.color;
    
            var region = [
                [x, y],
                [x + 1, y],
                [x + 1, y + 1],
                [x, y + 1],
                [x, y]
            ];
    
            var newColor = new SolidColor();
            newColor.rgb.red = color.rgb.red;
            newColor.rgb.green = 255 - color.rgb.green;
            newColor.rgb.blue = color.rgb.blue;
    
            doc.selection.select(region);
            doc.selection.fill(newColor);
    
        }
    }
    

    I’m not sure if there’s a prettier way of setting a pixel color than the select + fill trick.

    This script runs super slow, so maybe Photoshop scripts are not the best tool for pixel manipulation …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this questions might seem a little odd, but I want to make
I want to make a little tk app that continuous ping an ip and
I want to make a little script but I'm rather n00b in php so
I want to make a little php poll. The script should ask the users
Let's say I want to make a little wrapper along the lines of: def
I have a little program that I want to make open automatically when my
I am traversing a HTML document using javascript DOM. I want make a list
I want to make a little in-app demo like Tapbots does in Convertbot. Maybe
I want to make a little gallery and add next/previous buttons. I managed to
I want to make a little web-frontend for copying (rsync) and encoding (ffmpeg) files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.