Convert MHTML to Image – Cloud SDKs and REST API

MHTML to Image

Aspose.HTML Cloud v4.0 provides the simplest API to convert MHTML documents to Image file formats with high quality, easy and fast.

The MHTML format has gained popularity as an XML-based e-book format and designed to adapt the content’s presentation to the reader device. It is implemented as an archive file consisting of XHTML files carrying the content, images and other supporting files. Sometimes, it is required to get an image instead of MHTML documents, such as making them portable and easily shared on various devices, creating a picture gallery from eBooks, etc.

The article explains in a set of code examples how to convert an MHTML document to Image file formats such as JPEG, PNG, GIF, TIFF or BMP using Aspose.HTML Cloud SDKs and REST API calls. SDKs are available in PHP, C++, Python, C#, Ruby, Java, Android, Swift, and Node.js. We will consider various scenarios of MHTML to Image conversion: from storage to storage, from a local file system to the local file system, etc.

SDK Examples of MHTML to Image Conversion

A widespread use case for Aspose.HTML Cloud SDK functions is file processing and converting. Cloud SDK allows you to fetch an MHTML document from a storage location by its name or from a local file on your drive, convert it to a specified format, and save it to storage or your local drive. The following code examples demonstrate how to convert MHTML to Image for different cases using available SDKs.

Example 1. Convert MHTMLto JPG

JPG is one of the most commonly used image formats. Its uniqueness is the controlled loss of quality during compression. Therefore, it is widely used to store and send graphic content (photos, scanned copies, digitized images) over the Internet. Let’s look at an example of converting a local MHTML file to JPG format and saving the result to a local file system. The conversion occurs with default conversion options.

MHTML to JPG conversion occurs with the default conversion options: the resulting JPG document’s width and height correspond to A4, and all margins have zero value.

Example 2. Convert MHTML to PNG with explicitly specified options

PNG image format widely takes to transmit pictures over the network, display photos and graphics on web-pages and reserve in cloud storages. MHTML to PNG conversion may be required, for example, if you want to add a web page in a PowerPoint presentation, insert it on a blog for your readers, or send it by e-mail. The example below shows how to convert MHTML to PNG with explicitly specified options and save the result back to the local file system.

More details about available conversion parameters for MHTML files are in the SDK Conversion Options section.

Example 3. Convert MHTML to GIF inside cloud storage

Aspose.HTML Cloud allows you to get an MHTML file from your cloud storage and save conversion result back to cloud storage. The conversion occurs with default conversion options.

See Also