透明gif转PNG批量处理抗锯齿

发布于 2024-10-28 05:33:19 字数 291 浏览 6 评论 0原文

我有大量图像,这些图像最初具有黑色背景,然后去除纯黑色,使图像具有像素化的暗边缘。

我正在寻找一种方法来批量处理这些图像,以颜色擦除与透明像素相邻的黑色像素,或者平滑边缘,使黑色边缘不呈锯齿状。

我有 xnview、irfanview 和 GIMP,但除了使用 GIMP 手动操作之外,我找不到合适的方法来执行此操作,即在透明区域使用魔棒,增长一个像素,然后对黑色进行颜色擦除。

有什么想法吗?我说的是超过 800 张图像,因此批处理非常重要。它们是从 3D 模型自动生成的。

在此期间我会继续四处寻找!

I have a large amount of images which at first had a black background, then the solid black color was removed leaving the image with pixelated dark-edges.

I am looking for a way to batch process these images to either color-erase the black pixels adjacent to transparent pixels, or to smooth the edge leaving the black edges not as jagged.

I had xnview, irfanview, and GIMP, but I cannot find a suitable method for doing this other than manually with GIMP by using the magic wand on transparent area, growing by one pixel, and color-erasing the black color.

Any ideas? I'm talking over 800 images, so batch processing is pretty important. They are automatically generated from 3d models.

I'll keep looking around in the mean time!

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

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

发布评论

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

评论(1

朮生 2024-11-04 05:33:19

Photoshop 是可编写脚本的,据我所知 gimp 也是如此。 Photoshop 具有 vbscript、javascript 和 apple(脚本?)的脚本参考以及 PDF 格式埋藏在已安装文件夹中的示例。检查文档。

我抄袭了一种从论坛帖子中选择透明度的技术并将其移植到 vbscript 中。它创建一个临时操作,然后在(传递的)当前应用程序引用中选择当前图层的透明度。参考资料中介绍了打开文件、保存文件等的基础知识。

下面的 vbscript 示例将找到 Photoshop,将其置于最前面,然后尝试在当前打开的文档中加载透明度。 Obvious Man 表示,如果您尚未打开 PS 并加载文档,或者您的文档未应用透明度,则此操作将会失败。 YMMV。

Set appRef = CreateObject("Photoshop.Application")
appRef.BringToFront
loadTransparency appRef

    function loadTransparency(appRef)
        dim desc
        dim ref
        dim ref1

        set desc = CreateObject( "Photoshop.ActionDescriptor" )
        set ref = CreateObject( "Photoshop.ActionReference" )
        ref.putProperty appRef.charIDToTypeID( "Chnl" ), appRef.charIDToTypeID( "fsel" ) 
        desc.putReference appRef.charIDToTypeID( "null" ), ref 

        set ref1 = CreateObject( "Photoshop.ActionReference" )
        ref1.putEnumerated appRef.charIDToTypeID( "Chnl" ), appRef.charIDToTypeID( "Chnl" ), appRef.charIDToTypeID( "Trsp" )
        desc.putReference appRef.charIDToTypeID( "T   " ), ref1 

        appRef.ExecuteAction appRef.charIDToTypeID( "setd" ), desc, 3   '3 = no dialogs

    end function

Photoshop is scriptable, and AFAIK gimp is as well. Photoshop has scripting references for vbscript, javascript, and apple(script?) as well as samples buried in the installed folders in PDF format. Check the docs.

I cribbed a technique for selecting transparency from a forum post and ported it to vbscript. It creates a temporary Action which then selects the transparency of the current layer in the (passed) current application reference. The basics of opening files, saving files etc is covered in the references.

The vbscript sample below will find photoshop, bring it to the front, and then attempt to load the transparency in the currently open document. Obvious Man says that this will fail if you haven't already opened PS and loaded a document, or if your document has no transparency applied. YMMV.

Set appRef = CreateObject("Photoshop.Application")
appRef.BringToFront
loadTransparency appRef

    function loadTransparency(appRef)
        dim desc
        dim ref
        dim ref1

        set desc = CreateObject( "Photoshop.ActionDescriptor" )
        set ref = CreateObject( "Photoshop.ActionReference" )
        ref.putProperty appRef.charIDToTypeID( "Chnl" ), appRef.charIDToTypeID( "fsel" ) 
        desc.putReference appRef.charIDToTypeID( "null" ), ref 

        set ref1 = CreateObject( "Photoshop.ActionReference" )
        ref1.putEnumerated appRef.charIDToTypeID( "Chnl" ), appRef.charIDToTypeID( "Chnl" ), appRef.charIDToTypeID( "Trsp" )
        desc.putReference appRef.charIDToTypeID( "T   " ), ref1 

        appRef.ExecuteAction appRef.charIDToTypeID( "setd" ), desc, 3   '3 = no dialogs

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