Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to get image Thumbnail without open it?

how to get image Thumbnail without open it?

Scheduled Pinned Locked Moved C#
tutorialquestion
8 Posts 6 Posters 27 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Le rner
    wrote on last edited by
    #1

    hi all, is there any option to get image file thumbnail ,but without open the image file. please guide me for this. thanks in advance.

    Richard DeemingR OriginalGriffO L J 4 Replies Last reply
    0
    • L Le rner

      hi all, is there any option to get image file thumbnail ,but without open the image file. please guide me for this. thanks in advance.

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      Maybe hire a medium to generate their interpretation of the contents of a file they've never seen? :laugh: Seriously, how do you think it would be possible to generate a smaller version of the image in a file without opening that file to see what the image is? This sounds like an XY problem[^]. Perhaps if you ask for help with the issue you're actually trying to solve, rather than asking for help implementing the solution you think you need, then you might have better luck. :)


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      • L Le rner

        hi all, is there any option to get image file thumbnail ,but without open the image file. please guide me for this. thanks in advance.

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        To back up what Richard says, what you are asking for is logically impossible: it's like saying "write me a summary of this book, but don't read it first". You can't write an accurate summary without knowing what happens in the story! The same applies to images: you can't create a thumbnail without access to the original image. So as Richard suggests: think about the problem you are trying to solve instead of the solution you have conceived - there may be a better way to complete your task. Or even a possible one!

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        1 Reply Last reply
        0
        • L Le rner

          hi all, is there any option to get image file thumbnail ,but without open the image file. please guide me for this. thanks in advance.

          L Offline
          L Offline
          Le rner
          wrote on last edited by
          #4

          FileStream fs = new System.IO.FileStream(img_path, FileMode.Open, FileAccess.Read);
          img = Image.FromStream(fs);

          Image imgThumb = img.GetThumbnailImage(thumbnailSize.Width, thumbnailSize.Height, null, IntPtr.Zero);
          //imgThumb use it for thumbnail

          fs.Close();
          fs.Dispose();

          img.Dispose();

          i use this for getting thumbnail, but it takes time if file is large,or i take tumbnail of multiple big size images.... that's why i ask its possible to get image thumbnail without using the image file. is this possible with the use of "IExtractImage"

          D OriginalGriffO L 3 Replies Last reply
          0
          • L Le rner

            FileStream fs = new System.IO.FileStream(img_path, FileMode.Open, FileAccess.Read);
            img = Image.FromStream(fs);

            Image imgThumb = img.GetThumbnailImage(thumbnailSize.Width, thumbnailSize.Height, null, IntPtr.Zero);
            //imgThumb use it for thumbnail

            fs.Close();
            fs.Dispose();

            img.Dispose();

            i use this for getting thumbnail, but it takes time if file is large,or i take tumbnail of multiple big size images.... that's why i ask its possible to get image thumbnail without using the image file. is this possible with the use of "IExtractImage"

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            You're going to have the performance problem no matter what. Even using whatever interface that is, it's going to have to open the file and read the entire thing to generate the thumbnail.

            Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak

            1 Reply Last reply
            0
            • L Le rner

              FileStream fs = new System.IO.FileStream(img_path, FileMode.Open, FileAccess.Read);
              img = Image.FromStream(fs);

              Image imgThumb = img.GetThumbnailImage(thumbnailSize.Width, thumbnailSize.Height, null, IntPtr.Zero);
              //imgThumb use it for thumbnail

              fs.Close();
              fs.Dispose();

              img.Dispose();

              i use this for getting thumbnail, but it takes time if file is large,or i take tumbnail of multiple big size images.... that's why i ask its possible to get image thumbnail without using the image file. is this possible with the use of "IExtractImage"

              OriginalGriffO Offline
              OriginalGriffO Offline
              OriginalGriff
              wrote on last edited by
              #6

              As Dave has said, no - it's not possible. However, there are two things you might consider to speed things up: 1) Cache your thumbnails. Create a new folder (if it doesn't exist) below the source image folder called "Thumbs", and when you need a thumbnail check that folder first for a file of the same name. If it exists, just read the thumbnail file. If it doesn't, generate the thumbnail and add it to the Thumbs folder. That doesn't speed everything up, but the second and successive times it will. 2) Do the above, but add a background thread that checks the images folder for "missing thumbs" and create them as needed. That again doesn't speed anything up, but it moves the generation into the background and "pre-prepares" thumbs that haven't been asked for yet. Obviously, it'll take some work to ensure everything doesn't start colliding and your app crashes as a result, but it's that or insist that the images need to be added to your app before they are used (and creating the thumbnail then) - which may not be possible / convenient for your users / app.

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
              "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

              1 Reply Last reply
              0
              • L Le rner

                hi all, is there any option to get image file thumbnail ,but without open the image file. please guide me for this. thanks in advance.

                J Offline
                J Offline
                jschell
                wrote on last edited by
                #7

                Le@rner wrote:

                is there any option to get image file thumbnail ,but without open the image file.

                Using those requirements and NOTHING else, then yes. Create (or buy, acquire) say 100 or 1000 very small images. Then for each file assign one of those to the file either sequentially or randomly. The number of files will determine if you produce repeats. You could also just populate a small image with random data also. A variation of that is to use the name of the file and/or the current date/time as a seed for the random data.

                1 Reply Last reply
                0
                • L Le rner

                  FileStream fs = new System.IO.FileStream(img_path, FileMode.Open, FileAccess.Read);
                  img = Image.FromStream(fs);

                  Image imgThumb = img.GetThumbnailImage(thumbnailSize.Width, thumbnailSize.Height, null, IntPtr.Zero);
                  //imgThumb use it for thumbnail

                  fs.Close();
                  fs.Dispose();

                  img.Dispose();

                  i use this for getting thumbnail, but it takes time if file is large,or i take tumbnail of multiple big size images.... that's why i ask its possible to get image thumbnail without using the image file. is this possible with the use of "IExtractImage"

                  L Offline
                  L Offline
                  lmoelleb
                  wrote on last edited by
                  #8

                  Some file formats allow embedding a thumbnail in metadata. For example JPG allows it in the EXIF data section. Not all image formats support this, and even if they do, not all images will have it. And even if it is present, the quality might not be sufficient. I have not looked at it for years (decade+) so have no code nor libraries, but maybe googling "EXIF thumbnail c#" or similar will help.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups