convert tiff to jpg format

Viewed 45295

I have a tiff image with two pages. When I convert the file to jpg format I lost second pages. Is there any way to put two images on tiff file into one jpg file. Because of tiff files are too big I have to decrease their sizes. Is there any way to decrease tiff files size programmatically? It could also be a solution to my problem.

4 Answers
using System.Drawing;
using System.Drawing.Imaging;

Bitmap bm=Bitmap.FromFile("photo.tif");
bm.Save("photo.jpg",ImageFormat.Jpeg);
  public static class ConvertTiffToJpeg
    {
        static string base64String = null;
        public static string ImageToBase64(string tifpath)
        {
            string path = tifpath;
            using (System.Drawing.Image image = System.Drawing.Image.FromFile(path))
            {
                using (MemoryStream m = new MemoryStream())
                {
                    image.Save(m, ImageFormat.Jpeg);
                    byte[] imageBytes = m.ToArray();
                    base64String = Convert.ToBase64String(imageBytes);
                    return base64String;
                }
            }
        }
    }

< img src="data:image/jpeg;base64, @ConvertTiffToJpeg.ImageToBase64(@"c:\sample.tif")"/>

Related