从xcf(GIMP)文件C#获取图层属性

问题描述 投票:1回答:1

不久前我发现了一些C#代码,这有助于我从XCF文件中获取各个图层的详细信息。我目前可以提取“ x”,“ y”,“层名称”,“ x层”和“ y层”详细信息。现在,我需要图层的颜色,内容和旋转值(如果旋转)以及其他任何细节。谁能帮忙?

我的代码:

    private void Form1_Load(object sender, EventArgs e)
    {
        string inputPdf  = image_path + "offical_tour.xcf"; // GIMP file to load
        string outputPng = image_path + "output.png";       // output filename


        using (MagickImageCollection images = new MagickImageCollection(inputPdf))
        {
            int i = 0;

            foreach (var image in images)
            {
                if (i > 0)
                {
                    string layerFile = Path.Combine(image_path, image.Label + $".png");

                    image.Write(layerFile); // save the individual layers

                    // show some layer attributes
                    Console.WriteLine(image.Page.X + " x " + image.Page.Y + " = Layer:'" + image.Label + "' -- " + image.Width + " -- " + image.Height);
                }

                if (i++ == 0 || image.Compose != CompositeOperator.Over) continue;
            }
        }
    }
c# file attributes gimp
1个回答
0
投票

例如,您要查找的信息作为图层的“寄生虫”保留在Gimp中:

(text "aaaa")
(font "Roboto Heavy")
(font-size 60)
(font-size-unit pixels)
(antialias yes)
(language "cad")
(base-direction ttb-rtl)
(color (color-rgb 0 0 0))
(justify center)
(box-mode dynamic)
(box-unit pixels)
(hinting yes)

这是一个类似JSON的对象(但具有LISP / Scheme语法)。从Gimp 2.10开始,如果文本的特定部分具有特定格式,则text元素可以改为markup元素。]

(markup "<markup>plain<i>italic</i><b>bold</b></markup>")

当然,我不知道您的图书馆如何检索该信息...

© www.soinside.com 2019 - 2024. All rights reserved.