Quantcast
Channel: Adobe Community : Popular Discussions - Photoshop Scripting
Viewing all articles
Browse latest Browse all 12244

change white color to grey

$
0
0

//opening a file

 

 

var fileRef = File("D:/EL20427_02.jpg") ;

var docRef = app.open(fileRef) ;

 

var docWidth = docRef.width;

var docHeight = docRef.height;

var xPos = 0;

var yPos = 0;

// Create a color to be used with the fill command

var colorRef = new SolidColor ;

colorRef.rgb.red = 233 ;

colorRef.rgb.green = 233 ;

colorRef.rgb.blue = 233;

var sampler =docRef.colorSamplers.add([0, 0]);

for(xPos = 0; xPos <= docWidth; xPos++)

{

for(yPos = 0; yPos <= docHeight; yPos++)

{

 

sampler.move([xPos, yPos]);

        var color = sampler.color;

    if (color.rgb.hexValue == "FFFFFF") {

        var region = [

            [xPos, yPos],

            [xPos + 1, yPos],

            [xPos + 1, yPos + 1],

            [xPos, yPos + 1],

            [xPos, yPos]

        ];

 

 

docRef.selection.select(region);

        docRef.selection.fill(colorRef);

 

}

}

}

 

jpgFile = new File(""D:/temp_EL20427_02.jpg");

jpgSaveOptions = new JPEGSaveOptions() ;

jpgSaveOptions.embedColorProfile = true;

jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE ;

jpgSaveOptions.matte = MatteType.NONE ;

jpgSaveOptions.quality = 1 ;

app.activeDocument.saveAs(jpgFile, jpgSaveOptions, true, Extension.LOWERCASE);


Viewing all articles
Browse latest Browse all 12244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>