Merge JPG Files in Node.js

Install this image processing library in your Node.js-based project and merge JPG files instantly. Now, there is no need to opt for any third-party software or tools to combine JPG files. GroupDocs.Merger offers enterprise-level Cloud SDKs for multiple programming languages and no matter whether you are an expert or beginner-level developer, you can integrate and use these SDKs easily. However, in this blog post, we will learn how to merge JPG files in Node.js programmatically. Therefore, please go through this guide thoroughly to learn the steps and the code snippet to merge JPG files.

The following points will be covered in this blog post:

Image Processing Library Installation

First thing first, let’s install this free JPG merger library in our Node.js project. The installation process is just running a command in the terminal/CMD. However, you can leverage the rich-featured stack of GroupDocs.Merger Cloud SDK for Node.js right after the installation is done.

So, run the following command:

npm install groupdocs-merger-cloud

Next, please visit this guide to learn how to obtain API credentials (Client ID + Client Secret). Again, it’s super simple and you can generate API credentials without any hassle.

Merge JPG Files in Node.js Programmatically

Now, we are all ready to start writing code snippet to merge JPG files in Node.js. For this purpose, we already have uploaded two different JPG images to our API Cloud dashboard. You can upload the files manually or programmatically by calling the UploadFile method.

The following are the steps to combine JPG files programmatically:

  • Require the groupdocs-merger-cloud module in your project.
  • Get your API credentials from API Cloud Dashboard.
  • Invoke the fromKeys method of the DocumentApi class and pass the API credentials.
  • Instantiate an object of the JoinItem class that describes the document for the join operation.
  • Instantiate an instance of the FileInfo class.
  • Set the file path of the source JPG files by invoking the filePath property.
  • Create an object of the JoinOptions class.
  • Invoke the JoinItems property to assign the source document array.
  • Set the output path for generated merged JPG images.
  • Initialize an object of the JoinRequest class and pass it into the join method to merge JPG files.

Copy & paste the following code snippet to merge JPG files:

Once you run the server, you will find a new merged jpg file in the “Output” folder in the API Cloud dashboard, you can see the output file in the image below:

free jpg merger

Here you can download the generated JPG file manually or programmatically by calling this DownloadFile method.

Merge JPG Images Online

In addition to Cloud SDKs and REST APIs, there is an online tool to merge JPG files in the browser and this free JPG merger is powered by GroupDocs.Merger. It is easy to use and offers a user-friendly interface. In fact, there are multiple options to configure the request such as horizontal merge or vertical merge. Above all, there is no fee associated with this tool and you can use it to combine JPG files.

merge jpg images online

Final Thoughts

Thank you for reading this blog post and we hope you found it interesting. We are ending this guide here and will come up with a new topic soon. In this article, we covered how to merge JPG files in Node.js programmatically. In addition, we walked through some prominent methods exposed by GroupDocs.Merger Cloud SDK for Node.js. Further, you can visit the documentation to learn about other methods and the source code is available on GitHub. Lastly, do not miss to give it a try to our Cloud APIs here.

Finally, groupdocs.cloud is writing new articles. So, please stay in touch for the latest updates.

Ask a question

You can let us know about your questions or queries on our forum.

Frequently Asked Questions – FAQs

What software can merge JPG?

GroupDocs.Merger Cloud SDK for Node.js offers methods and properties to merge JPG files programmatically. Further, you can explore this image processing library here.

How to combine 2 JPG into 1 JPG?

Please visit this link to know the answer in detail.

See Also