how to get image Thumbnail without open it?
-
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.
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
-
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.
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!
-
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.
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 thumbnailfs.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"
-
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 thumbnailfs.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"
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
-
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 thumbnailfs.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"
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!
-
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.
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.
-
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 thumbnailfs.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"
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.