Image Files Extension "JPG" vs "JPEG"

Is there an option to have Aspose save JPEG images with the file extension jpg instead of “jpeg” ?
I need to have the images load into a viewer which does not understand the “jpeg” extension.
Thanks! -John

This message was posted using Aspose.Live 2 Forum

Hi

Thanks for your inquiry. Could you please clarify, you need to export each page of the document as JPEG images, but need to specify JPG extension? If so, you can simply use the following code:

Document doc = new Document(@"Test001\in.doc");
doc.SaveToImage(0, 1, @"Test001\out.jpg", null);

Best regards.

Thank you -

What I need to do is convert a Doc to HTML, and the Doc has Jpeg images in it. When the Aspose convert saves the images, they are saved with the “jpeg” extension, is there a way to force Aspose to save the images with a “jpg” extension?

Thanks! -John

Hi John,
It seems that .NET handles Images of .jpg type as ImageFormat.Jpeg. Aspose.Word uses these functions from .NET so .jpg images are saved automatically as .jpeg when converting to Html.
To change the extenstion of the image files generated when converting, you need to implement a HtmlExportSavingEvent. Use this code below which sets this up and changes the extentsion of all images while exporting to “.jpg”

static void Main()
{
    Document doc = new Document(dataDir + "Test Document.doc");
    doc.SaveOptions.HtmlExportImageSaving += new ExportImageSavingEventHandler(SaveOptions_HtmlExportImageSaving);
    doc.Save(dataDir + "Test Document Out.html");
}
void SaveOptions_HtmlExportImageSaving(object sender, ExportImageSavingEventArgs e)
{
    e.ImageFileName = Path.ChangeExtension(e.ImageFileName, ".jpg");
}

Thanks,