JPEG Thumbnail

Discussions about image processing and document imaging.
Post Reply
fnaudeau
Posts: 14
Joined: Thu Dec 25, 2014 7:25 pm

JPEG Thumbnail

Post by fnaudeau » Thu Dec 25, 2014 8:12 pm

Hello,

I wanted to load the embedded thumbnail of a JPEG image as fast as possible. I didn't find a way to do it. Indeed, CreateThumbnail and Create ThumbnailHQ seem to load the complete image and resized it, so it's not very efficient. Can someone guide me on how to do that ?

Many thanks.
Frédéric.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: JPEG Thumbnail

Post by Loïc » Fri Dec 26, 2014 10:34 am

Hi Frédéric,

There is dedicated overloads of the CreateThumbnailHQ() method for such purpose:

from file
from stream

Hope this helps!

With best regards,

Loïc

fnaudeau
Posts: 14
Joined: Thu Dec 25, 2014 7:25 pm

Re: JPEG Thumbnail

Post by fnaudeau » Sat Jan 03, 2015 5:10 pm

Hi Loïc,

CreateThumbnailHQ doesn't seem to "only" read the embedded thumbnail. First, we have to load the image to get imageId, then call the CreateThumbnailHQ. These operations takes too much time. Normally an extraction of embedded JPEG takes around 15 milliseconds which is not the case here. Moreother I don't know the size of the embedded thumbnail so I cannot give these informations to the parameters.
Normally, I use the following code:

Code: Select all

                   
                    using (FileStream stream = File.OpenRead(image.MediaPath))
                    {
                        BitmapFrame frame = BitmapFrame.Create(stream, BitmapCreateOptions.DelayCreation, BitmapCacheOption.Default);
                        if (frame.Thumbnail != null)
                        {
                            using (var fileStream = new FileStream(thumbnailPath, FileMode.Create))
                            {
                                BitmapEncoder encoder = new BmpBitmapEncoder();
                                encoder.Frames.Add(BitmapFrame.Create(frame.Thumbnail));
                                encoder.Save(fileStream);                                                                
                            }
                        }
                    }
Which works well, but I'm wondering if I can use GDPicture to replace this code.

Thanks.
Frédéric.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: JPEG Thumbnail

Post by Loïc » Sun Jan 04, 2015 3:32 pm

Hello Féréric,

I've edited my reply above. Please check the first link I've provided which target to the overload that creates a thumbnail image from a file path. There is no need to load the image from your side.

Let me know if this is still unclear.

With best regards,

Loïc

fnaudeau
Posts: 14
Joined: Thu Dec 25, 2014 7:25 pm

Re: JPEG Thumbnail

Post by fnaudeau » Sun Jan 04, 2015 4:24 pm

Hello,

Well, I use the following code:

Code: Select all

                    GdPictureImaging imaging = new GdPictureImaging();
                    int id = imaging.CreateThumbnailHQ(image.MediaPath, 0, 0, imaging.ARGB(255,255,0,0));
                    imaging.SaveAsBMP(id, thumbnailPath);
                    imaging.ReleaseGdPictureImage(id);
It works, but it generates a thumbnail instead of getting the embedded one. I saw that on the output high quality image and the time it takes to generate ( around 500ms ).
I've checked on disk and it saved a full resolution image size instead of the embedded thumbnail size.
So it doesn't seem to achieve what I want.

Frédéric.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: JPEG Thumbnail

Post by Loïc » Sun Jan 04, 2015 4:37 pm

Hello Frédéric,

Could you share the image you ware using?
If it contains confidential data you can sen it through https://www.gdpicture.com/support/getting-support-from-our-team

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests