编写 Photoshop 差异混合模式脚本

发布于 2024-12-15 11:01:38 字数 168 浏览 0 评论 0原文

我经常有两组以相同方式命名的图片,我想编写检查差异的过程。我正在寻找基本检查,如果两个图像之间没有差异,则丢弃其中一个,如果存在单个像素差异,则保留两个图像。对于那些质疑在 Photoshop 中执行此操作是否明智的人,这是对已经运行的另一个脚本的补充,并且此可选检查将有助于减少我必须上传的文件数量。我将不胜感激的帮助。

I regularly have two sets of pictures named the same way and I would like to script the process of checking for differences. I'm looking for a basic check, if there is no differences between the two images, discard one of them, if there is a single pixel difference, keep both. For those who question the wisdom of doing this in photoshop, this is an addition to another script that is already running and this optional check will help reduce the number of files I have to upload. I would appreciate the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

始终不够爱げ你 2024-12-22 11:01:38

如果您确实必须在 Photoshop 中执行此操作,这就是我的建议:

var doc1 = app.open(new File("~/Desktop/test1.bmp"));
var doc2 = app.open(new File("~/Desktop/test2.bmp"));

doc2.selection.selectAll();
doc2.selection.copy();

app.activeDocument = doc1;
var newLayer = doc1.paste();
newLayer.blendMode = BlendMode.DIFFERENCE;

var histogram = doc1.histogram;
for (var i = 1; i < histogram.length; ++i) {
    if (histogram[i] > 0) {
        alert('Different!');
        break;
    }
}

将第二张图片粘贴到第一张图片中,并将生成的图层的混合模式设置为差异。如果两张图片相同,则生成的图片应为全黑。因此,我检查除 0 之外的任何颜色值在直方图中是否有任何像素。

我假设这两个图像具有相同的大小。

If you really have to do this in Photoshop, this is how I'd propose it:

var doc1 = app.open(new File("~/Desktop/test1.bmp"));
var doc2 = app.open(new File("~/Desktop/test2.bmp"));

doc2.selection.selectAll();
doc2.selection.copy();

app.activeDocument = doc1;
var newLayer = doc1.paste();
newLayer.blendMode = BlendMode.DIFFERENCE;

var histogram = doc1.histogram;
for (var i = 1; i < histogram.length; ++i) {
    if (histogram[i] > 0) {
        alert('Different!');
        break;
    }
}

I paste the second picture into the first one and set the resulting layer's blend mode to difference. If the two pictures are identical, the resulting picture should be all black. I therefore check if any color values apart from 0 have any pixels in the histogram.

I assumed the two images have the same size.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文