不久前,我发现了一些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;
}
}
}