Convert Markdown to Image – Cloud SDKs and REST API

Markdown to Image

Converting Markdown (MD) to image formats can be useful for embedding Markdown content in environments or platforms where Markdown rendering is not directly supported. It makes it easy to share Markdown content on social media, embed it in presentations, or include it in websites without Markdown rendering capabilities.

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

The article explains in a set of code examples how to convert an Markdown 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 Markdown to Image conversion: from storage to storage, from a local file system to the local file system, etc.

SDK Examples of Markdown 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 Markdown 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 Markdown to Image for different cases using available SDKs.

Example 1. Convert Markdown to 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 Markdown file to JPG format and saving the result to a local file system. The conversion occurs with default conversion options.

Markdown 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 Markdown 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. Markdown 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 Markdown to PNG with explicitly specified options and save the result back to the local file system.

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

Example 3. Convert Markdown to GIF inside cloud storage

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

See Also