问题
How can I get the properties of ai (Adobe Illustrator) or eps file i.e resolution in dpi etc. I need to check this properties when uploading file to server.
Also is there any DLL to convert ai/eps to standards image format(jpg, gif, png etc.)?
回答1:
use ImageMagickNET.dll through this you can convert the .ai or .eps files into .jpg format..
c# code:
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();
}
}
To get the ai files properties like width, height,number of pages and title, use itextsharp.dll
code:
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;
}
}
}
回答2:
use "identify -verbose image.eps" to give the metadata information of EPS file and AI file.
来源:https://stackoverflow.com/questions/12409452/how-to-get-the-properties-of-an-ai-or-eps-file