This project has moved and is read-only. For the latest updates, please go here.

Possible issue writing to stream

Mar 25, 2014 at 12:37 AM
Using the following file as my source(.eps):

https://www.dropbox.com/s/b4pn07h4w4mnp65/PreviewforEPS.eps

This conversion works fine going from .eps to .jpg:
   using (MagickImage image2 = new MagickImage("fileSource.eps"))
                    {
                        image2.Strip();
                        image2.Write("fileDestination.jpg");
                    }
The following does NOT. It works for some other conversions, but not .eps to .jpg
   using (MagickImage image2 = new MagickImage("fileSource.eps"))
                    {
                        image2.Strip();
                        Stream fs = new FileStream(fileDestination.jpg", FileMode.OpenOrCreate);
                        image2.Write(fs);
                    }
Thanks.
Mar 25, 2014 at 7:12 AM
Your second example is writing an eps file. When you write to a stream the Format of the input stream is used. If you want to write to a different format you will have to set the Format property of your MagickImage.
using (MagickImage image2 = new MagickImage("fileSource.eps"))
{
    image2.Strip();

    // This uses the format of the input image.
    using (Stream fs = new FileStream("thisIsActualyAn.eps", FileMode.OpenOrCreate))
    {
        image2.Write(fs);
    }

    image2.Format = MagickFormat.Jpeg;
    using (Stream fs = new FileStream("fileDestination.jpg", FileMode.OpenOrCreate))
    {
        image2.Write(fs);
    }
}
Mar 26, 2014 at 2:44 AM
Thank you very much. I was really sure that I tried that, Your documentation was very clear so I guess I didn't try it when I thought I did. Thanks again.