Convert EPUB to Image using Cloud SDK – Aspose.HTML

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

The EPUB format has gained popularity as an XML-based e-book format and designed to adapt the content’s presentation to the reader device. EPUB, an XML-based digital book format, is widely compatible with devices such as smartphones, tablets, and computers. 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 EPUB 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 EPUB document to Image file formats such as JPEG, PNG, GIF, TIFF or BMP using Aspose.HTML Cloud SDK and REST API calls. SDKs are available in PHP, C++, Python, C#, Ruby, Java, Android, Swift, and Node.js. We will consider a few scenarios of EPUB to Image conversion:

  • Convert a local EPUB file to an image and save the result to your local file system. For this scenario, we will look at conversion with default conversion options and explicitly specified options options.
  • Convert EPUB to Image inside cloud storage with default conversion options.

SDK Examples of EPUB 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 EPUB 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 the storage or the local drive. The following code examples demonstrate how to convert EPUB to Image for different cases using available SDKs.

Example 1. Convert EPUB 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.

Consider converting an EPUB document initially located on a local file system to JPG format. The resultant file is then saved back to the local file system. The conversion occurs with default conversion options.

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

More details about available conversion parameters for EPUB files are in the SDK Conversion Options article.

Example 3. Convert EPUB to GIF inside cloud storage

For those who need to convert an EPUB file stored in cloud storage to an image GIF format, the process is as follows. The EPUB file is accessed from the cloud storage, converted to the GIF format, and then saved back to the same cloud storage location.

See Also