如何读取使用C#EPS的性质或颜色的信息? [英] How to read the property or color information of EPS using c#?

查看:492
本文介绍了如何读取使用C#EPS的性质或颜色的信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的要求是读50多个EPS文件和导出EPS的财产/彩色模式,这可能吗?色彩模式灰度,RGB和CMYK。到目前为止,我试过的BitmapImage阅读EPS,但我没有得到运气。在BitmapImage的不读EPS,因为它是矢量格式(我在堆栈溢出某处读取)。任何一个可以帮助我走出来读取EPS文件并显示图像,即图像的色彩格式?我尝试了一些code请温柔我是初学者到编程世界....

My requirement is to read the 50 more EPS files and export the property/color mode of the EPS, is this possible? the color modes are Gray-scale, RGB and CMYK. So far I tried the BitmapImage to read the EPS but I am NOT getting the luck. the BitmapImage does not read the EPS because it is vector format (I read somewhere in stack-overflow). Can any one helps me out to read the EPS file and display the format of image i.e., color of image? I tried some code please be gentle I am beginner to the programming world....

C#

string imageloc = @"D:\Image";
string[] files = Directory.GetFiles(imageloc);
foreach (string file in files)
{
     BitmapImage source = new BitmapImage(new System.Uri(file));
     int bitsPerPixel = source.Format.BitsPerPixel;
     Console.Write("File Scanning--> " + file + "property is" +bitsPerPixel+"\n");
}

猜测可能使用ImageMagick读取文件格式?

Possible guessing to read the file format using imagemagick?

推荐答案

这需要 Magick.Net ,这是在阿尔法目前。为了能够读取EPS文件还需要安装 GhostScript的

This requires Magick.Net, which is in alpha currently. To be able to read EPS files you'll also need to install GhostScript.

我也不得不添加引用 System.Drawing中获得 Magick.Net 正常工作。

I also had to add a reference to System.Drawing to get Magick.Net to work properly.

Magick.Net 可以使用安装的NuGet

namespace ConsoleApplication3
{
    using System;
    using System.IO;

    using ImageMagick;

    class Program
    {
        static void Main(string[] args)
        {
            foreach (var epsFile in Directory.GetFiles(@"c:\tmp\eps", "*.eps"))
            {
                using (var image = new MagickImage())
                {
                    image.Read(epsFile);

                    Console.WriteLine("file: {0}   color space: {1}", epsFile, image.ColorSpace);
                }
            }
        }
    }
}


file: c:\tmp\eps\a.eps   color space: CMYK
file: c:\tmp\eps\b.eps   color space: CMYK
file: c:\tmp\eps\c.eps   color space: CMYK
file: c:\tmp\eps\circle.eps   color space: sRGB
file: c:\tmp\eps\d.eps   color space: CMYK
file: c:\tmp\eps\e.eps   color space: CMYK
file: c:\tmp\eps\f.eps   color space: CMYK
file: c:\tmp\eps\football_logo.eps   color space: sRGB
file: c:\tmp\eps\fsu_logo.eps   color space: sRGB
file: c:\tmp\eps\g.eps   color space: CMYK
file: c:\tmp\eps\icam_logo.eps   color space: sRGB
Press any key to continue . . .

这篇关于如何读取使用C#EPS的性质或颜色的信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆