How to merge JPG images using Node.js via Java

JPG Merger Node.js via Java API

GroupDocs.Merger allows developers to combine multiple JPG documents in the preferred order and save them as a single file.

About JPG File Format

Files having extension .JPG represent Bitmap Image files that are used to store bitmap digital images. These images are independent of graphics adapter and are also called device independent bitmap (DIB) file format. This independency serves the purpose of opening the file on multiple platforms such as Microsoft Windows and Mac. The JPG file format can store data as two-dimensional digital images in both monochrome as well as color format with various colour depths.

Download and Configure

You can download GroupDocs.Merger for Node.js via Java from official website Downloads section.

Source JPG images

“Sample1.jpg” “Sample2.jpg” “Sample3.jpg”

How to merge JPG files in vertical mode

The following example demonstrates how to merge image files in vertical mode with several lines of nodejs-java code:

  • Create an instance of Merger class and pass source image file path as a constructor parameter. You may specify absolute or relative file path as per your requirements.
  • Create an instance of ImageJoinOptions class and pass enum value of ImageJoinMode as a constructor parameter.
  • Add another image file to merge with join method and pass instance of ImageJoinOptions class as a method parameter. Repeat this step for other image documents you want to merge.
  • Call Merger class save method and specify the filename for the merged image file as parameter.
const merger = new groupdocs.merger.Merger('c:/sample1.jpg');
const imageJoinModeVertical = groupdocs.merger.ImageJoinMode.Vertical;
const imageJoinOptions = new groupdocs.merger.ImageJoinOptions(imageJoinModeVertical);
merger.join('c:/sample2.jpg', imageJoinOptions);
merger.join('c:/sample3.jpg', imageJoinOptions);
return merger.save('c:/merged.jpg');

Result merged JPG image

“Merged.jpg”

Code Examples

Please find more use-cases and complete Node.js via Java sources of our backend and frontend examples and try them for free!

Merge JPG Live Demo

GroupDocs.Merger for Node.js via Java provides an online JPG Merger App, which allows you to try it for free and check its quality and accuracy.