When the Save Html- how to save pictures as jpg or gif format

When the Save Html, how to save pictures as jpg or gif format.
For example:

document.Save(Server.MapPath("~/upload/template/demo.html"), SaveFormat.Html);
// Document contains pictures,currently save as png format

Thank you


Thanks for your request. During saving to HTML images are saved in the same format as they are stored in the original document. Why do you need to save them as JPEG? PNG is better in terms of quality.
Best regards.

thank you for my question. Because capacity of Jpg or gif format is less than png format.If a document has many pictures, I want to switch jpg or gif format.


Thanks for your request. You can loop through all shapes in the document and convert all images to JEPG format. For instance, see the following code:

// Open source document.
Document doc = new Document(@"Test001\in.doc");
// Get all shapes from the document.
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
// Loop through shapes collection and if the shape contains an image convert it to JPEG.
foreach(Shape shape in shapes)
    if (shape.HasImage)
        using(MemoryStream inputStream = new MemoryStream(shape.ImageData.ImageBytes))
        using(Image image = Image.FromStream(inputStream))
        using(MemoryStream jpegStream = new MemoryStream())
            image.Save(jpegStream, ImageFormat.Jpeg);
// Save output document.

Hope this helps.
Best regards.