Copy link to clipboard
Copied
I have a large 2400x2400 pixel image, with guides every 24 pixels vertically and horizontally, creating a grid of 100 blocks wide x 100 blocks tall. Only 1 pixel per 24x24 grid has color - it's in the same pixel position in every 24x24 grid (e.g. 10th px column, 24th px row). See bottom row of pixels - rest is black (see below). Is there a way to export the sequencing of the colors, one row at a time, left-to-right. For example...
Color 1 = Upper-left 24x24 grid
Color 2 = 2nd grid...
color ...
Color 101 = first grid of 2nd row
etc.
Final output would be just 10K rows of data, 1 color per row...
Try this. It will round the values to intergers. It will place a file on your desktop witht he name colorValues.txt. It will just list the RGB values separated by a comma, and the next set with a semicolon. This is only for the file without the black. With 10,000 colors, this will take a while to run. Getting color values with Javascript is slow.
#target photoshop
var file = new File('~/Desktop/colorValues.txt')
app.preferences.rulerUnits = Units.PIXELS;
var doc = activeDocument;
var docSize
...
Copy link to clipboard
Copied
how about a way to reduce the above to 1000x1000 pixel image only - retaining only the non-black pixels?
Each 24x24 pixel area contains only 1 colored pixel (rest of 24x24 grid is black). Pixel is always in the same position within each grid. Need a script or process that essentially reduces this image down to a 1000x1000 image retaining only the colored pixels per 24x24 region.
Copy link to clipboard
Copied
I had some difficulty understanding your post. In spite of that I would like remind you of three Photoshop commands that may put you on the right track.
The bottom image is a 3200% enlarged view of a new file 24px x24px View > Show > Pixel Grid. It was used to create a pattern Edit > Define Pattern.
The long strip is a 1200% enlarged view of a strip 240 px wide 24 px deep to which was applied Edit > Fill > Pattern and from the drop down menu the last pattern is the one just created. This is a row. A column would be just as easy to create.
It suggests that masked layers may offer the solution to your design. Tap the image for an enlarged view
Copy link to clipboard
Copied
@Norman Sanders thanks for the thoughts - each of the colored pixels is a random, different color, so I'm looking for a solution to reduce the 2400x2400 image down to just the 100x100 color pixels (removing all the black) - I'll then run a script against the image to output the 10,000 colors, each as a separate line of text.
Copy link to clipboard
Copied
I'm thinking that would need a script if it was doable. Will it always be the same exact pixel size, and will the coloured pixels always be in exactly same positions?
Copy link to clipboard
Copied
So do you want just an image that is reduced in size, with each of the 1x1 color pixels showing? Or do you want a text file listing the color values? What color space are you using: Abobe RGB, RGB, etc?
Copy link to clipboard
Copied
Ultimately, I just want a txt file listing the 10K color values. As interim, was trying to reduce the image down to just the 10K pixels (100x100), as I figured it would be easier to find a script to produce the text file if I didn't have all the extra pixels. I don't know how to check the color space. Under Image>Mode it just says RGB, 8-bit. What does that mean?
Copy link to clipboard
Copied
Okay - so i've manually reduced the image down to the 100x100 image of just the target pixels. Now I just have to figure out how to translate it to a txt file of 10k rows, 1 row per pixel color.
Copy link to clipboard
Copied
Do you want the color values rounded off to interger values?
Copy link to clipboard
Copied
Try this. It will round the values to intergers. It will place a file on your desktop witht he name colorValues.txt. It will just list the RGB values separated by a comma, and the next set with a semicolon. This is only for the file without the black. With 10,000 colors, this will take a while to run. Getting color values with Javascript is slow.
#target photoshop
var file = new File('~/Desktop/colorValues.txt')
app.preferences.rulerUnits = Units.PIXELS;
var doc = activeDocument;
var docSize = doc.width.value
//var docNewSize = docSize/24
var cString = ''
for(var i=.5;i<doc.height;i++){
for(var j=.5;j<parseFloat(doc.width);j++){
if(j<parseFloat(doc.width)){
var cPt = [j,i];
cString += getColor (cPt)
if(j<parseFloat(doc.width)-.6){cString+='; ' }
else{
cString+='\n'}
}
}
}
writeFile ();
function getColor(pts){
doc.colorSamplers.removeAll();
var cS = doc.colorSamplers.add(pts);
var rgbC = new SolidColor
rgbC.rgb.red = cS.color.rgb.red;
rgbC.rgb.green = cS.color.rgb.green;
rgbC.rgb.blue = cS.color.rgb.blue;
return rgbC.rgb.red.toFixed(0) +', '+rgbC.rgb.green.toFixed(0) +', ' + rgbC.rgb.blue.toFixed(0)
}
function writeFile() {
file.encoding = "UTF8";
file.open("w", "TEXT", "????");
//unicode signature, this is UTF16 but will convert to UTF8 "EF BB BF"
file.write("\uFEFF");
file.lineFeed = "unix";
file.write(cString);
file.close();
};
Copy link to clipboard
Copied
Thank you!!!
was able to figure out with this direction!