Merge JPG

How to Merge JPG to JPG online

The JPG is a widely used compressed image format for containing digital images. It is the most common image format used in digital cameras, different operating systems, and on the Internet. It’s a type of image format that is saved using lossy compression and is popular for sharing photos/images on the internet and between Mobile & PC users. We may have a requirement to merge JPG images online, so in this article, we are going to discuss the details of how JPG merge can be accomplished using Java SDK.


Aspose.PDF Cloud SDK for Java enables you to manipulate images where you can resize, scale, rotate, flip, search, crop & convert images to other supported document formats. In order to install the SDK, please add the following details to pom.xml of the maven build type project.

    <name>Aspose Cloud Repository</name>


Now we also need to create a free account by visiting Aspose.Cloud dashboard. If you have GitHub or Google account, simply Sign Up. Otherwise, click on the Create a new Account button.

Merge JPG using Java

Please follow the instructions given below to combine JPG images.

  • First of all, create an object of PdfApi while passing ClientID and ClientSecret details are arguments
  • Secondly, create a blank PDF file using the putCreateDocument(…) method of PdfApi class to create an empty PDF document
  • Now call postInsertImage(..) method which takes input PDF filename, PageNumber, XY coordinates, and image file name as arguments
  • Repeat the method to insert more images
  • Finally, call the putPageConvertToJpeg(…) method to convert PDF to JPG images and save the output in cloud storage

Combine JPG Online using cURL Commands

The REST APIs can also be accessed via cURL commands and in the following section, we are going to merge JPG images using cURL commands. So the pre-requisite is to generate a JWT access token based on client credentials.

curl -v "" \
-d "grant_type=client_credentials&client_id=bbf94a2c-6d7e-4020-b4d2-b9809741374e&client_secret=1c9379bb7d701c26cc87e741a29987bb" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Now that we have generated the JWT token, please execute the following command to generate a blank PDF file.

curl -v -X PUT "" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>"

Now we need to execute the following command to insert JPG images into the PDF document.

curl -v -X POST "" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>" \
-H  "Content-Type: multipart/form-data" \
-d {"image":{}}

Repeat the above command to insert more images and then execute the following command to convert the first page of PDF to JPG format and save the output in cloud storage.

curl -v -X PUT "" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>"

The sample PDF and resultant image generated are attached below.


In this article, we have discussed the details of how we can merge JPG to JPG using Java code snippets. At the same time, we have also explored the option to merge JPG files using cURL commands. Furthermore, the API is also capable of performing other amazing features and their details can be found in Product Documentation. In case you encounter any issues while using the API, please feel free to contact the Free product support forum.

We also recommend visiting the following blogs for information on: