Avatar of zimmer9
zimmer9
Flag for United States of America

asked on 

Can you suggest a way I can shrink the file size of output image files?

I am developing a C# application using VS2010 and .Net Framework 4.0

I use the following function to combine 2 check image files into 1 check image file with one check image appearing below the other.

However, the output image files created are rather large in file size.

Can you suggest a way I can shrink the size of the output image files and there is a lot of empty space between the 2 check images
in the output check image file.

 public static void ProcessImage(string checkImgPrefix, string directory)
        {
            string tif1 = directory + checkImgPrefix + "_Front.tif";
            string tif2 = directory + checkImgPrefix + "_Rear.tif";
            string tif3 = directory + checkImgPrefix + ".ard.out";

            Image img1 = Image.FromFile(tif1);
            Image img2 = Image.FromFile(tif2);

            int width = Math.Max(img1.Width, img2.Width);
            int height = img1.Height + img2.Height;

            Bitmap img3 = new Bitmap(width, height);
            Graphics g = Graphics.FromImage(img3);

            g.Clear(Color.Black);
            g.DrawImage(img1, new Point(0, 0));
            g.DrawImage(img2, new Point(0, img1.Height));

            g.Dispose();
            img1.Dispose();
            img2.Dispose();

            img3.Save(tif3, System.Drawing.Imaging.ImageFormat.Tiff);
            img3.Dispose();
        }
C#Images and Photos

Avatar of undefined
Last Comment
Joe Winograd

8/22/2022 - Mon