Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# web page show 2nd page of tiff on an image control

  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;
                }
            }
        }
    }
Comment

c# web page show 2nd page of tiff on an image control

public static string[] ConvertTiffToJpeg(string fileName) 
{ 
        using (Image imageFile = Image.FromFile(fileName)) 
        { 
            FrameDimension frameDimensions = new FrameDimension( 
                imageFile.FrameDimensionsList[0]); 

            // Gets the number of pages from the tiff image (if multipage) 
            int frameNum = imageFile.GetFrameCount(frameDimensions); 
            string[] jpegPaths = new string[frameNum]; 

            for (int frame = 0; frame < frameNum; frame++) 
            { 
                // Selects one frame at a time and save as jpeg. 
                imageFile.SelectActiveFrame(frameDimensions, frame); 
                using (Bitmap bmp = new Bitmap(imageFile)) 
                { 
                    jpegPaths[frame] = String.Format("{0}{1}{2}.jpg",  
                        Path.GetDirectoryName(fileName), 
                        Path.GetFileNameWithoutExtension(fileName),  
                        frame); 
                    bmp.Save(jpegPaths[frame], ImageFormat.Jpeg); 
                } 
            } 

            return jpegPaths; 
        } 
} 
Comment

PREVIOUS NEXT
Code Example
Csharp :: C# a program to reverse each word in the given string. 
Csharp :: How to use multiple Commands for one ViewModel 
Csharp :: use different database with entitymanagerfactory 
Csharp :: how to remove black top bar in asp.net 
Csharp :: a infinite loop in text box update ui c# 
Csharp :: enemy turret one direction ahooting script unity 2d 
Csharp :: generate random string 
Html :: html pound symbol 
Html :: marquee speed 
Html :: espacio html 
Html :: html mailto 
Html :: how to make a whatsapp hyperlink html 
Html :: twig count array 
Html :: include script in html 
Html :: Uncaught ReferenceError: jQuery is not defined 
Html :: bootstrap col-md-5 center 
Html :: centre text bootstrap 
Html :: how to link html pages in different folders 
Html :: bootstrap div vertical center 
Html :: bootstrap modal fullscreen 
Html :: html start 
Html :: font awesome 5 cdn 
Html :: a href type submit 
Html :: set icon for html page tab 
Html :: react html mouseover 
Html :: bootstrap 4 vertical align td 
Html :: ngfor with index 
Html :: footer ionic 
Html :: html template 
Html :: how to add placeholder in type date 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =