如何获取.ai或.eps文件的属性?

时间:2012-09-13 15:12:27

标签: c# asp.net eps

如何获取ai(Adobe Illustrator)或eps文件的属性,即dpi等分辨率。 我需要在将文件上传到服务器时检查此属性。

还有没有DLL将ai / eps转换为标准图像格式(jpg,gif,png等)?

2 个答案:

答案 0 :(得分:2)

use ImageMagickNET.dll through this you can convert the .ai or .eps files into .jpg format..

c#c​​ode:

  public partial class Form1 : Form
    {

        Process ffmpeg;
        string video;
        string thumb;
        public Form1()
        {
            InitializeComponent();
        }
        private void button4_Click(object sender, EventArgs e)
        {
            ffmpeg = new Process();

            ffmpeg.StartInfo.Arguments = "convert \"" + .ai file path + "\" -background white -flatten -density 300 -colors 512 -antialias  -normalize -units PixelsPerInch -quality 100 -colorspace RGB -resize 3425x3425  \"D:\\GRAPHICS SEARCH ENGINE\\GRAPHICS IMAGES\\AI\\" convert.jpg\"";

            ffmpeg.StartInfo.FileName = ("C:\\Program Files (x86)\\ImageMagick-6.5.3-Q16\\convert.exe");
            ffmpeg.Start();

         }
    }

获取宽度,高度,页数和标题等ai文件属性, 使用itextsharp.dll

代码:

using System;
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Linq; 
using System.Text;
using System.Windows.Forms;
using iTextSharp.text; 
using iTextSharp.text.pdf;

namespace pdfreared { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

    private void button1_Click(object sender, EventArgs e)
    {
        PdfReader reader = new PdfReader(@"D:\Files Formats\Icon.ai");
        int n = reader.NumberOfPages;
        label4.Text = n.ToString();

        // size of the first page
        Rectangle psize = reader.GetPageSize(1);
        float width = psize.Width;
        label1.Text ="Width= " + Convert.ToString(width);
        float height = psize.Height;
        label2.Text = "Height = " + Convert.ToString(height);
      //  reader.Metadata.

        Console.WriteLine("Size of page 1 of {0} => {1} × {2}", n, width, height);
        // file properties
        Dictionary<string, string> infodict = reader.Info;
        foreach (KeyValuePair<string, string> kvp in infodict)
        {
            Console.WriteLine(kvp.Key + " => " + kvp.Value);
            label3.Text = kvp.Key + " => " + kvp.Value;


        }

    }
}

答案 1 :(得分:0)

使用“identify -verbose image.eps”来提供EPS文件和AI文件的元数据信息。