Comparing layers for equality [2011]
Copy link to clipboard
Copied
Is it possible to compare two different layers to see if they are in fact the same image?
I'm actually working on a game at the moment. The game map was created by using game sprites created by other people. For example, I found 5 different pictures of trees, and copy pasted them into photoshop multiple times to create a forest. I have 100 trees in my photoshop document, but in reality, they are all made up of only 5 images. I want to save out each of these trees into a format usable by my game engine. I want to save each layer as an image, but avoid saving duplicates. Thus the need to compare layers for equality.
Is it possible to do this within a photoshop script? Thanks for any help you can provide.
Explore related tutorials & articles
Copy link to clipboard
Copied
hm, what i'm thinking of does not work 100%, but no other idea comes to my mind.
Define 5 different variables as empty array
Now go through all your layers, apply the average filter on each and with the color sampler get the r, g and b values.
If the values do not exist in neither of those 5 variables, save them as one of the variables and save the image (e.g. by copying the layer to another document)
Should work in estimated 95% of the cases 😉
Copy link to clipboard
Copied
Make just the two layers visible. Set the blend mode on the top layer to Difference. Then try this:
app.activeDocument.histogram.slice(1).toString().replace(/,0/g, "") == "0"
This will evaluate to true if the layers are identical and false if there are any differences.
Copy link to clipboard
Copied
X, that is how I would check using the UI as a visual check, I think it could work… but wouldn't this only work in the instance of them being on top of each other? ( pixel for pixel ) I read this that a forest may be a couple of tress as such but my guess is they are placed at random locations… or did I just overlook some of your clever trickery/voodoo…?
Copy link to clipboard
Copied
but wouldn't this only work in the instance of them being on top of each other?
That bit of code presumes:
- The layers are in the same document
- The layers are the only two layers visible
- The content of the layers is aligned.
- The layers have simple content (no layer masks, vector masks, layer styles)
There may be other assumptions that I'm making, but this is all that I can think of.
For the trees/forest problem, I would iterate though the tree-layers.
Create a new document that is as large as the largest tree-layer in the forest.
Hide the background layer.
Copy the first layer to the new document.
Copy the second layer to the new doc
Do the layer comparison code from above my previous post
If the layers are the same, delete the new one.
Go to the next layer in the forest document.
Copy and compare the new layer against each layer in the new document.
Delete it if it's a dupe.
When you're done, the new document should have only the unique trees.
Copy link to clipboard
Copied
Ah… no Voodoo then this time… I was thinking a similar thing only… I think I would have probably aligned all layers in the document centrally ( except b/g ) then worked down the stack… removing untill uniques are left… I couldn't think of another method other than 'difference' to check thou…
Copy link to clipboard
Copied
Thanks for the great suggestions. I'll give them a shot over the weekend and let you know how it goes.
Cheers ^^
Copy link to clipboard
Copied
Hi , Did any one work on this script .
Copy link to clipboard
Copied
Hi , Did any one work on this script .
By Chandrakanthi26574696ugut
This topic thread is around 14 years old, are your criteria the same? In it's simplest form, you only need an action, not a script. What would such a script offer? Is this only for two layers to compare in a single document? Can you screenshot the layers panel and provide any further info?
Copy link to clipboard
Copied
My requirement is to highlight each difference on the difference layer, after comparison of 2 layers using the Difference blend mode.
Currently we are using the action for comparing and viewing the difference for pdfs. However small differences like text in small fonts are not visible on the difference layer. So I wanted to script this to highlight all the difference areas.
Is this acheivable ?
Copy link to clipboard
Copied
Please provide samples (the pdfs and the file you create for checking).
Copy link to clipboard
Copied
What resolution are you rasterizing the PDF files?
You can view the histogram for the merged difference layers, however, for an exaggerated visual running equalize is a good approach for the action.
It might also help to only compare RGB luminosity for a single channel, or the L channel of Lab mode to avoid insignificant colour variations.
Copy link to clipboard
Copied
I am sharing the pdf files . Here you may not have small text difference. I am not an expert in photoshop, so i am not able to answer the queries related to resolution. In the pdf files , when there are small text differences, they are not visible to the eye. So need a mechanism to highlight each of the areas which are different in the layer.
Copy link to clipboard
Copied
Have you tried Acrobat’s Compare Files?
Copy link to clipboard
Copied
Pesonally I don’t like relying on »Difference« but prefer to switch on/of the pages to compare visually.
But you could add a Threshold-Layer (or any other Adjustment Layer to increase the effect) to the image created with below code.
There is also the issue of comparing preview-pdfs (which are often RGB) with CMYK-pdfs (possibly with Spot Colors).
Edited 2025-02-27
// tries to create a file comparing all pages of two cmyk-pdfs;
// 2025, use it at your own risk;
/* dialog for pdf-selection */
if (ScriptUI.environment.keyboardState.shiftKey == true) {var theRes = 300}
else {var theRes = 150};
var theFile1 = File.openDialog("please select the first pdf", checkForPDF, false);
var theFile2 = File.openDialog("please select the second pdf", checkForPDF, false);
if (theFile1 && theFile2) {
/* the open options */
var pdfOpenOpts = new PDFOpenOptions;
pdfOpenOpts.antiAlias = true;
pdfOpenOpts.bitsPerChannel = BitsPerChannelType.EIGHT;
pdfOpenOpts.cropPage = CropToType.TRIMBOX;
pdfOpenOpts.mode = OpenDocumentMode.CMYK;
pdfOpenOpts.resolution = theRes;
pdfOpenOpts.suppressWarnings = true;
pdfOpenOpts.usePageNumber = true;
var thePdf = compareMultipagePDF(theFile1, theFile2, pdfOpenOpts);
revealAll ();
};
/* function to compare all pages of two pdfs */
function compareMultipagePDF(myPDFFile1, myPDFFile2) {
var secondShorter = false;
/* suppress dialogs */
var theDialogSettings = app.displayDialogs;
app.displayDialogs = DialogModes.NO;
var myCounter = 1;
var myBreak = false;
while(myBreak == false){
pdfOpenOpts.page = myCounter;
try {
var thePdf = app.open(myPDFFile1, pdfOpenOpts);
thePdf.flatten();
thePdf.layers[0].isBackgroundLayer = false;
thePdf.layers[0].name = myPDFFile1.name+"_"+myCounter;
if (myCounter == 1) {
var theFile = thePdf
}
else {
thePdf.layers[0].duplicate(theFile, ElementPlacement.PLACEATBEGINNING);
thePdf.close(SaveOptions.DONOTSAVECHANGES)
};
try {
var theSecondPdf = app.open(myPDFFile2, pdfOpenOpts);
theSecondPdf.flatten();
theSecondPdf.layers[0].isBackgroundLayer = false;
theSecondPdf.layers[0].name = myPDFFile2.name+"_"+myCounter;
theSecondPdf.layers[0].duplicate(theFile, ElementPlacement.PLACEATBEGINNING);
theSecondPdf.close(SaveOptions.DONOTSAVECHANGES);
var theSecond = activeDocument.activeLayer;
theSecond.blendMode = BlendMode.DIFFERENCE;
var id556 = charIDToTypeID( "GrpL" );
executeAction( id556, undefined, DialogModes.NO );
// mark differences;
mergVisibleToNewLayer();
//setBlendIf (16, 16);
var theBlendIfThisArray = [ [9,9,255,255], [0,0,255,255], [0,0,255,255], [0,0,255,255] ];
var theBlendIfUnderlyingArray = [ [0,0,255,255], [0,0,255,255], [0,0,255,255], [0,0,255,255] ];
blendIfThisAndUnderlying (theBlendIfThisArray, theBlendIfUnderlyingArray);
activeDocument.activeLayer.applyMaximum(10);
cmykChannelMixer();
groupSelectedLayers (myCounter);
activeDocument.activeLayer.merge();
var theGroup = activeDocument.activeLayer;
applyLayerStyleStroke(5, 255, 0, 0);
theGroup.fillOpacity = 0;
theSecond.blendMode = BlendMode.NORMAL;
}
catch (e) {secondShorter = true}
}
catch (e) {
try {
var theSecondPdf = app.open(myPDFFile2, pdfOpenOpts);
theSecondPdf.close(SaveOptions.DONOTSAVECHANGES);
alert (theFile2.name+" seems to have more pages than "+theFile1.name)
}
catch (e) {}
myBreak = true
};
myCounter = myCounter + 1;
};
if (secondShorter == true) {alert (theFile1.name+" seems to have more pages than "+theFile2.name)};
/* reset dialogmodes */
app.displayDialogs = DialogModes.ERROR;
};
/* open pdf page */
function openPDFPage (myPDFFile, pdfOpenOpts, myCounter) {
var thePdf = app.open(myPDFFile, pdfOpenOpts);
thePdf.flatten();
thePdf.layers[0].isBackgroundLayer = false;
thePdf.layers[0].name = myPDFFile.name+"_"+myCounter;
return thePdf
};
/* filter-function for pdf-files */
function checkForPDF (theFile) {
if (theFile.name.slice(-4) == ".pdf" || theFile.constructor.name == "Folder") {return true}
else {return false}
};
////// reveal all //////
function revealAll () {
var idRvlA = charIDToTypeID( "RvlA" );
executeAction( idRvlA, undefined, DialogModes.NO );
};
////// layer via copy //////
function mergVisibleToNewLayer (){
var desc23 = new ActionDescriptor();
desc23.putBoolean( stringIDToTypeID( "duplicate" ), true );
executeAction( stringIDToTypeID( "mergeVisible" ), desc23, DialogModes.NO );
};
////// blend-if-settings //////
function setBlendIf (a, b) {
var idsetd = charIDToTypeID( "setd" );
var desc2 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref1.putEnumerated( idLyr, idOrdn, idTrgt );
desc2.putReference( idnull, ref1 );
var idT = charIDToTypeID( "T " );
var desc3 = new ActionDescriptor();
var idBlnd = charIDToTypeID( "Blnd" );
var list1 = new ActionList();
var desc4 = new ActionDescriptor();
var idChnl = charIDToTypeID( "Chnl" );
var ref2 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idChnl = charIDToTypeID( "Chnl" );
var idGry = charIDToTypeID( "Gry " );
ref2.putEnumerated( idChnl, idChnl, idGry );
desc4.putReference( idChnl, ref2 );
var idSrcB = charIDToTypeID( "SrcB" );
desc4.putInteger( idSrcB, 0 );
var idSrcl = charIDToTypeID( "Srcl" );
desc4.putInteger( idSrcl, 0 );
var idSrcW = charIDToTypeID( "SrcW" );
// lower value;
desc4.putInteger( idSrcW, a );
var idSrcm = charIDToTypeID( "Srcm" );
// higher value;
desc4.putInteger( idSrcm, b );
var idDstB = charIDToTypeID( "DstB" );
desc4.putInteger( idDstB, 0 );
var idDstl = charIDToTypeID( "Dstl" );
desc4.putInteger( idDstl, 0 );
var idDstW = charIDToTypeID( "DstW" );
desc4.putInteger( idDstW, 255 );
var idDstt = charIDToTypeID( "Dstt" );
desc4.putInteger( idDstt, 255 );
var idBlnd = charIDToTypeID( "Blnd" );
list1.putObject( idBlnd, desc4 );
desc3.putList( idBlnd, list1 );
var idLefx = charIDToTypeID( "Lefx" );
var desc5 = new ActionDescriptor();
var idScl = charIDToTypeID( "Scl " );
var idPrc = charIDToTypeID( "#Prc" );
desc5.putUnitDouble( idScl, idPrc, 423.333316 );
var idLefx = charIDToTypeID( "Lefx" );
desc3.putObject( idLefx, idLefx, desc5 );
var idLyr = charIDToTypeID( "Lyr " );
desc2.putObject( idT, idLyr, desc3 );
executeAction( idsetd, desc2, DialogModes.NO );
};
////// group //////
function groupSelectedLayers (theName) {
var desc159 = new ActionDescriptor();
var ref114 = new ActionReference();
var idlayer = stringIDToTypeID( "layer" );
var idordinal = stringIDToTypeID( "ordinal" );
var idtargetEnum = stringIDToTypeID( "targetEnum" );
var idnull = stringIDToTypeID( "null" );
var idname = stringIDToTypeID( "name" );
ref114.putEnumerated(idlayer, idordinal, idtargetEnum);
desc159.putReference(idnull, ref114 );
desc159.putString(idname, "aaa" );
executeAction( stringIDToTypeID( "groupLayersEvent" ), desc159, DialogModes.NO );
var desc63 = new ActionDescriptor();
var ref37 = new ActionReference();
ref37.putEnumerated( idlayer, idordinal, idtargetEnum );
desc63.putReference( idnull, ref37 );
var desc64 = new ActionDescriptor();
desc64.putString(idname, theName);
desc63.putObject(stringIDToTypeID( "to" ), idlayer, desc64);
executeAction(stringIDToTypeID( "set" ), desc63, DialogModes.NO)
};
////// make stroke //////
function applyLayerStyleStroke (theWitdh, theR, theG, theB) {
// =======================================================
var idsetd = charIDToTypeID( "setd" );
var desc12 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref7 = new ActionReference();
var idPrpr = charIDToTypeID( "Prpr" );
var idLefx = charIDToTypeID( "Lefx" );
ref7.putProperty( idPrpr, idLefx );
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref7.putEnumerated( idLyr, idOrdn, idTrgt );
desc12.putReference( idnull, ref7 );
var idT = charIDToTypeID( "T " );
var desc13 = new ActionDescriptor();
var idScl = charIDToTypeID( "Scl " );
var idPrc = charIDToTypeID( "#Prc" );
desc13.putUnitDouble( idScl, idPrc, 100.000000 );
var idFrFX = charIDToTypeID( "FrFX" );
var desc14 = new ActionDescriptor();
var idenab = charIDToTypeID( "enab" );
desc14.putBoolean( idenab, true );
var idStyl = charIDToTypeID( "Styl" );
var idFStl = charIDToTypeID( "FStl" );
desc14.putEnumerated( idStyl, idFStl, charIDToTypeID( "OutF" ) );
var idPntT = charIDToTypeID( "PntT" );
var idFrFl = charIDToTypeID( "FrFl" );
var idSClr = charIDToTypeID( "SClr" );
desc14.putEnumerated( idPntT, idFrFl, idSClr );
var idMd = charIDToTypeID( "Md " );
var idBlnM = charIDToTypeID( "BlnM" );
var idNrml = charIDToTypeID( "Nrml" );
desc14.putEnumerated( idMd, idBlnM, idNrml );
var idOpct = charIDToTypeID( "Opct" );
var idPrc = charIDToTypeID( "#Prc" );
desc14.putUnitDouble( idOpct, idPrc, 100.000000 );
var idSz = charIDToTypeID( "Sz " );
var idPxl = charIDToTypeID( "#Pxl" );
desc14.putUnitDouble( idSz, idPxl, theWitdh );
var idClr = charIDToTypeID( "Clr " );
var desc15 = new ActionDescriptor();
var idRd = charIDToTypeID( "Rd " );
desc15.putDouble( idRd, theR );
var idGrn = charIDToTypeID( "Grn " );
desc15.putDouble( idGrn, theG );
var idBl = charIDToTypeID( "Bl " );
desc15.putDouble( idBl, theB );
var idRGBC = charIDToTypeID( "RGBC" );
desc14.putObject( idClr, idRGBC, desc15 );
var idFrFX = charIDToTypeID( "FrFX" );
desc13.putObject( idFrFX, idFrFX, desc14 );
var idLefx = charIDToTypeID( "Lefx" );
desc12.putObject( idT, idLefx, desc13 );
executeAction( idsetd, desc12, DialogModes.NO );
};
////// set blend if settings for this and underlying //////
function blendIfThisAndUnderlying (thisNumbers, underlyingNumbers) {
// =======================================================
var idsetd = charIDToTypeID( "setd" );
var desc11 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref8 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref8.putEnumerated( idLyr, idOrdn, idTrgt );
desc11.putReference( idnull, ref8 );
var idT = charIDToTypeID( "T " );
var desc12 = new ActionDescriptor();
var idBlnd = charIDToTypeID( "Blnd" );
var list3 = new ActionList();
var desc13 = new ActionDescriptor();
var idChnl = charIDToTypeID( "Chnl" );
var ref9 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idChnl = charIDToTypeID( "Chnl" );
var idGry = charIDToTypeID( "Gry " );
ref9.putEnumerated( idChnl, idChnl, idGry );
desc13.putReference( idChnl, ref9 );
var idSrcB = charIDToTypeID( "SrcB" );
desc13.putInteger( idSrcB, thisNumbers[0][0] );
var idSrcl = charIDToTypeID( "Srcl" );
desc13.putInteger( idSrcl, thisNumbers[0][1] );
var idSrcW = charIDToTypeID( "SrcW" );
desc13.putInteger( idSrcW, thisNumbers[0][2] );
var idSrcm = charIDToTypeID( "Srcm" );
desc13.putInteger( idSrcm, thisNumbers[0][3] );
var idDstB = charIDToTypeID( "DstB" );
desc13.putInteger( idDstB, underlyingNumbers[0][0] );
var idDstl = charIDToTypeID( "Dstl" );
desc13.putInteger( idDstl, underlyingNumbers[0][1] );
var idDstW = charIDToTypeID( "DstW" );
desc13.putInteger( idDstW, underlyingNumbers[0][2] );
var idDstt = charIDToTypeID( "Dstt" );
desc13.putInteger( idDstt, underlyingNumbers[0][3] );
var idBlnd = charIDToTypeID( "Blnd" );
list3.putObject( idBlnd, desc13 );
/*var desc14 = new ActionDescriptor();
var idChnl = charIDToTypeID( "Chnl" );
var ref10 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idChnl = charIDToTypeID( "Chnl" );
var idRd = charIDToTypeID( "Rd " );
ref10.putEnumerated( idChnl, idChnl, idRd );
desc14.putReference( idChnl, ref10 );
var idSrcB = charIDToTypeID( "SrcB" );
desc14.putInteger( idSrcB, thisNumbers[1][0] );
var idSrcl = charIDToTypeID( "Srcl" );
desc14.putInteger( idSrcl, thisNumbers[1][1] );
var idSrcW = charIDToTypeID( "SrcW" );
desc14.putInteger( idSrcW, thisNumbers[1][2] );
var idSrcm = charIDToTypeID( "Srcm" );
desc14.putInteger( idSrcm, thisNumbers[1][3] );
var idDstB = charIDToTypeID( "DstB" );
desc14.putInteger( idDstB, underlyingNumbers[1][0] );
var idDstl = charIDToTypeID( "Dstl" );
desc14.putInteger( idDstl, underlyingNumbers[1][1] );
var idDstW = charIDToTypeID( "DstW" );
desc14.putInteger( idDstW, underlyingNumbers[1][2] );
var idDstt = charIDToTypeID( "Dstt" );
desc14.putInteger( idDstt, underlyingNumbers[1][3] );
var idBlnd = charIDToTypeID( "Blnd" );
list3.putObject( idBlnd, desc14 );
var desc15 = new ActionDescriptor();
var idChnl = charIDToTypeID( "Chnl" );
var ref11 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idChnl = charIDToTypeID( "Chnl" );
var idGrn = charIDToTypeID( "Grn " );
ref11.putEnumerated( idChnl, idChnl, idGrn );
desc15.putReference( idChnl, ref11 );
var idSrcB = charIDToTypeID( "SrcB" );
desc15.putInteger( idSrcB, thisNumbers[2][0] );
var idSrcl = charIDToTypeID( "Srcl" );
desc15.putInteger( idSrcl, thisNumbers[2][1] );
var idSrcW = charIDToTypeID( "SrcW" );
desc15.putInteger( idSrcW, thisNumbers[2][2] );
var idSrcm = charIDToTypeID( "Srcm" );
desc15.putInteger( idSrcm, thisNumbers[2][3] );
var idDstB = charIDToTypeID( "DstB" );
desc15.putInteger( idDstB, underlyingNumbers[2][0] );
var idDstl = charIDToTypeID( "Dstl" );
desc15.putInteger( idDstl, underlyingNumbers[2][1] );
var idDstW = charIDToTypeID( "DstW" );
desc15.putInteger( idDstW, underlyingNumbers[2][2] );
var idDstt = charIDToTypeID( "Dstt" );
desc15.putInteger( idDstt, underlyingNumbers[2][3] );
var idBlnd = charIDToTypeID( "Blnd" );
list3.putObject( idBlnd, desc15 );
var desc16 = new ActionDescriptor();
var idChnl = charIDToTypeID( "Chnl" );
var ref12 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idChnl = charIDToTypeID( "Chnl" );
var idBl = charIDToTypeID( "Bl " );
ref12.putEnumerated( idChnl, idChnl, idBl );
desc16.putReference( idChnl, ref12 );
var idSrcB = charIDToTypeID( "SrcB" );
desc16.putInteger( idSrcB, thisNumbers[3][0] );
var idSrcl = charIDToTypeID( "Srcl" );
desc16.putInteger( idSrcl, thisNumbers[3][1] );
var idSrcW = charIDToTypeID( "SrcW" );
desc16.putInteger( idSrcW, thisNumbers[3][2] );
var idSrcm = charIDToTypeID( "Srcm" );
desc16.putInteger( idSrcm, thisNumbers[3][3] );
var idDstB = charIDToTypeID( "DstB" );
desc16.putInteger( idDstB, underlyingNumbers[3][0] );
var idDstl = charIDToTypeID( "Dstl" );
desc16.putInteger( idDstl, underlyingNumbers[3][1] );
var idDstW = charIDToTypeID( "DstW" );
desc16.putInteger( idDstW, underlyingNumbers[3][2] );
var idDstt = charIDToTypeID( "Dstt" );
desc16.putInteger( idDstt, underlyingNumbers[3][3] );
var idBlnd = charIDToTypeID( "Blnd" );
list3.putObject( idBlnd, desc16 );*/
desc12.putList( idBlnd, list3 );
var idLefx = charIDToTypeID( "Lefx" );
var desc17 = new ActionDescriptor();
var idScl = charIDToTypeID( "Scl " );
var idPrc = charIDToTypeID( "#Prc" );
desc17.putUnitDouble( idScl, idPrc, 423.333316 );
var idLefx = charIDToTypeID( "Lefx" );
desc12.putObject( idLefx, idLefx, desc17 );
var idLyr = charIDToTypeID( "Lyr " );
desc11.putObject( idT, idLyr, desc12 );
executeAction( idsetd, desc11, DialogModes.NO );
};
////// apply threshold //////
function applyThreshold (theValue) {
var desc232 = new ActionDescriptor();
desc232.putInteger( stringIDToTypeID( "level" ), theValue );
executeAction( stringIDToTypeID( "thresholdClassEvent" ), desc232, DialogModes.NO );
};
////// channel mixer //////
function cmykChannelMixer () {
var idpercentUnit = stringIDToTypeID( "percentUnit" );
var idchannelMixer = stringIDToTypeID( "channelMixer" );
var desc5 = new ActionDescriptor();
var idpresetKind = stringIDToTypeID( "presetKind" );
var idpresetKindType = stringIDToTypeID( "presetKindType" );
var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );
desc5.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );
var idmonochromatic = stringIDToTypeID( "monochromatic" );
desc5.putBoolean( idmonochromatic, true );
var idgray = stringIDToTypeID( "gray" );
var desc6 = new ActionDescriptor();
var idcyan = stringIDToTypeID( "cyan" );
desc6.putUnitDouble( idcyan, idpercentUnit, 25.000000 );
var idmagenta = stringIDToTypeID( "magenta" );
desc6.putUnitDouble( idmagenta, idpercentUnit, 25.000000 );
var idyellowColor = stringIDToTypeID( "yellowColor" );
desc6.putUnitDouble( idyellowColor, idpercentUnit, 25.000000 );
var idblack = stringIDToTypeID( "black" );
desc6.putUnitDouble( idblack, idpercentUnit, 25.000000 );
var idchannelMatrix = stringIDToTypeID( "channelMatrix" );
desc5.putObject( idgray, idchannelMatrix, desc6 );
executeAction( idchannelMixer, desc5, DialogModes.NO );
};
Copy link to clipboard
Copied
However small differences like text in small fonts are not visible on the difference layer.
That seems peculiar; with what resolution did you convert the images?
Is transparency involved?
Edit: Double-post with regard to the resolution … just missed the post apparently.
Copy link to clipboard
Copied
is it possible to mark all areas , after setting up the difference mode ?
Copy link to clipboard
Copied
I edited the code.
Copy link to clipboard
Copied
Thank you for taking the time and editing the code. The marking helps in identifying the differences easily. However there are 2 observations
The entire area with difference is not getting marked, because the width is fixed . Can that be worked on ?
Also there are some differences which are not detected, what may be the reason ? For example an entire box was missing , text alignment diffference was not detected .
Copy link to clipboard
Copied
The entire area with difference is not getting marked, because the width is fixed . Can that be worked on ?
Please post screenshots to clarify what you mean.
Also there are some differences which are not detected, what may be the reason ? For example an entire box was missing , text alignment diffference was not detected .
Yeah, I noticed that after some testing, too; if the difference is only in one channel (like black text) the difference in the luminance is too small.
I’ll amend the code with a Channel Mixer application.
Copy link to clipboard
Copied
Hi
Thank you for responding. I have attached orginal file and correct files to look at the differnce. I have also attached the screenshot of major differences missing . There is a area on the top right near the barcode, where the bg color difference is not detected. Also on top the there is pixel difference is on the full length of that area, which is not marked . At the bottom the red box difference is not detected.
Thank you again for the help.
Copy link to clipboard
Copied
Have you tried the amended code?
Copy link to clipboard
Copied
Thanks a million for the latest amends . Its flawless.
I have one more request addition to the same script,
Is it possible to create one more additional layer, which will show the differences in basic difference mode , i.e blending the layers with 50 % opacity and similarity in black color ?
Copy link to clipboard
Copied
I don’t understand, please provide a file that illustrates the set-up you have in mind.
Copy link to clipboard
Copied
I am attaching the action file that creates the difference layer. Can this also be added in that script provided by you, so that a new layer will be created in similar way as in the action also. This layer should be in addition to the functionality in the script.


-
- 1
- 2