Let’s develop a JPG to JPG merger using this C# image library. There are many scenarios when you need to merge multiple images into a single image file. So, automating this whole process will give your business software a competitive edge. Therefore, in this blog post, we will learn how to merge JPG to JPG in C# using the methods exposed by this powerful library. By the end of this article, you will be able to write code snippets to achieve this functionality.
The following sections will be covered in this guide:
C# image library installation
How to Merge JPG to JPG in C#
So far, you have installed this C# image library in your .NET application. Therefore, you are ready to start writing code to build a JPG to JPG merger programmatically.
Please follow the steps and the code snippets mentioned below:
- Call the Size property to get the resulting image size.
- Loop through the image paths, load the image one by one by invoking the Load method of the Image class and add to the imageSizes list.
- Calculate the width and height of the image.
- Initialize a new instance of the FileCreateSource class.
- Create a new object of the JpegOptions class.
- Invoke the Create method that creates a new image using the specified create options.
- Loop through the images, load the images by calling the Load method.
- Initialize a new instance of the Rectangle structure with the specified location and size.
- Invoke the SaveArgb32Pixels method to save the 32-bit ARGB pixels.
- Call the Save method to save the image’s data to the specified stream in the specified file format according to the save options.
Copy & paste the following code into your main file:
You can see the output in the image below:
Get a Free License
You can avail a free temporary license to try the API without evaluation limitations.
This is the end of this blog post. You have learned how to merge JPG to JPG in C# using this C# image library. Moreover, you can build a JPG to JPG merger for your business application programmatically. Further, do not forget to visit the documentation to know other cool features.
Moreover, we suggest you follow our Getting Started guide.
Finally, conholdate.com is writing new blog posts. Therefore, please stay in touch for regular updates.
Ask a question
You can let us know about your questions or queries on our forum.
How do I combine JPG files into one JPG?
How do I combine JPEG files into one document?
You can leverage this C# image library to combine JPEG/JPG image files into one document programmatically.