Friday, January 22, 2010

Convert an image from one format to another from AX

Here's is how you can convert an image from one format to another:

static void Job5(Args _args)
    System.Drawing.Image    image;

    image = System.Drawing.Image::FromFile(@"C:\sandbox\test.tif");

    image.Save(@"C:\sandbox\newtest.jpg", System.Drawing.Imaging.ImageFormat::get_Jpeg());

The new files tend to be a bit larger. You have to work with the ImageCodecInfo class from .NET to fix this.