1
votes

I have just come across a scenario where I need to convert EPS files to JPG file on upload.

What I would preferably like to do is, when uploading the EPS files; I would like to keep the original EPS file and save it in background under a folder and also convert the EPS image into JPG and save it in another folder.

Is this something that can be achieved using C#? If so could someone please direct me in the right direction?

I have used ImageMagick and GhostScript and from the command line I can convert EPS into JPG but not sure how should I go embedding it in a C# application and convert EPS into JPG on upload.

Any help or any demo doing the same will be a great help.

Thanks, Zulfi

3
This good enough for you? imagemagick.org/script/api.php#dot-net (note that this was the first hit on searching "imagemagick .net")Piskvor left the building

3 Answers

1
votes

You may consider parsing the EPS file yourself, honestly.

You can probably find various file format information online, such as wotsit.org (which has been around since the 90s, back when people still wrote what they needed from scratch.)

This has the upside of not needing to embed external artifacts into your solution, nor incurring licensing costs. It obviously has the downside of a personal time investment in research and development. Afterward, perhaps you can share your code/library with others that doesn't have attribution, copyleft or licensing costs.

Good luck!

1
votes

After researching available solutions for a while, I came across this utility that seems to work well. It's $200/server. VeryDoc's utility does not rely on any third party libraries (unlike other solutions) and it offers conversion between many formats. The available command line options:

C:\>ps2img.exe
-------------------------------------------------------
Description:
Convert PS (Postscript) and EPS to TIF, TIFF, JPG, GIF, PNG, BMP, WMF, EMF, PCX, TGA, etc. formats
Usage: ps2img [options] <-i PS File> [-o Output]
-i [input PS]   : Input PS filename
-o [output file]: Output TIFF filename
-g              : Convert to 8-bit grayscale image file, this option is only available while bitcount equal 8 (-b 8)
-m              : Set output to multi-page TIFF file, the default is output to single page TIFF files
-r [resolution] : Set resolution in generated image files
-r 300          : Set horizontal and vertical resolution to 300 DPI
-r 200x300      : Set horizontal and vertical resolution to 200x300 DPI
-r 204x98       : Set horizontal and vertical resolution to 204x98 DPI
-f [first Page] : First page to convert
-l [last Page]  : Last page to convert
-c [compress]   : Set compression method in generated image files (for tif only)
    -c none     : Create TIFF file without compression
    -c lzw      : Compress TIFF using LZW arithmetic
    -c jpeg     : Compress TIFF using JPEG arithmetic
    -c packbits : Compress TIFF using packbits arithmetic
    -c g3       : Compress TIFF using CCITT G3 arithmetic
    -c g4       : Compress TIFF using CCITT G4 arithmetic
    -c ClassF   : Compress TIFF into Fax compatible ClassF 204x98 format
    -c ClassF196: Compress TIFF into Fax compatible ClassF 204x196 format
-q [quality]    : Set quality in created image files (for jpeg image only)
-b [bit count]  : Set bit count in generated image files
-?              : Help
-------------------------------------------------------
Example:
    ps2img -i C:\input.ps -o C:\output.tif
    ps2img -i C:\input.eps -o C:\output.tif
    ps2img -m -i C:\input.ps -o C:\output.tif
    ps2img -c lzw -i C:\input.ps -o C:\output.tif
    ps2img -q 80 -i C:\input.ps -o C:\output.jpg
    ps2img -b 4 -i C:\input.ps -o C:\output.tif
    ps2img -i C:\input.ps -o C:\output.tif -b 1 -c ClassF -r 204x98 -m
    ps2img -f 1 -l 9 C:\input.ps -o C:\output.jpg
    ps2img -i C:\*.ps -o C:\*.pcx

One alternative, ImageMagick (free) + GhostScript is reportedly expensive at $32,000+/year + a $5,000 setup fee.

-1
votes

using ImageMagickNET.dll through this you can convert the .eps,.ai,.psd,.tga files to .jpg format.. c# code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using SimplePsd;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Data.SqlClient;
using System.Configuration;
using System.Media;
using System.DirectoryServices;
using System.Diagnostics;
namespace Master_Graphics
{
    public partial class Form1 : Form
    { 

        private SimplePsd.CPSD psd = new SimplePsd.CPSD();
        Process ffmpeg;
        string video;
        string thumb;
        public Form1()
        {
            InitializeComponent();
        }
 private void button4_Click(object sender, EventArgs e)
        {
ffmpeg = new Process();
                ffmpeg.StartInfo.Arguments = "convert \"" + listBox1.SelectedItem.ToString() + "\" -background white -flatten -density 300 -colors 512 -antialias  -normalize -units PixelsPerInch -quality 100 -colorspace RGB -resize 3425x3425  \"D:\\GRAPHICS SEARCH ENGINE\\GRAPHICS IMAGES\\EPS\\" + final + ".jpg\"";
                ffmpeg.StartInfo.FileName = ("C:\\Program Files (x86)\\ImageMagick-6.5.3-Q16\\convert.exe");
                ffmpeg.Start();
}