VintaSoft Imaging .NET SDK 15.0: Documentation for .NET developer
In This Topic
    TIFF: How to change resolution for all images in multipage TIFF file?
    In This Topic
    Here is C# code that shows how to change resolution for all images in TIFF file and save changes to the source TIFF file:
    namespace ConsoleApp1
    {
        class Program
        {
            static void Main(string[] args)
            {
                // open file stream
                using (System.IO.FileStream fs = new System.IO.FileStream("multipage.tif", System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite))
                {
                    // create image collection
                    using (Vintasoft.Imaging.ImageCollection images = new Vintasoft.Imaging.ImageCollection())
                    {
                        // add images from file stream to the image collection
                        images.Add(fs);
    
                        // for each image in image collection
                        for (int i = 0; i < images.Count; i++)
                        {
                            // change image resolution
                            images[i].Resolution = new Vintasoft.Imaging.Resolution(200, 200);
                        }
    
                        // create TIFF encoder
                        Vintasoft.Imaging.Codecs.Encoders.TiffEncoder encoder = new Vintasoft.Imaging.Codecs.Encoders.TiffEncoder();
                        // specify that TIFF encoder must save image collection to the source file and switch image collection to the saved file
                        encoder.SaveAndSwitchSource = true;
    
                        // save image collection to the source TIFF file
                        images.SaveSync(fs, encoder);
                    }
                }
            }
        }
    }