ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How to update thumbnail with the main image
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

paul

Australia
3 Posts

Posted - Oct 15 2020 :  04:38:23  Show Profile  Reply
Hi All,

I am using the code below to crop an image and then to resize the image. This is working fine. The only issue I have is it doesn't seem to update the thumbnail. I ran the code and then checked the images in windows explorer. At first I didn't think it had worked, as all the images were the same. But when I opened the image, it was cropped and resized correctly.

How do I make sure the thumbnail is also updated?

Thanks,
Paul

// imgDest is a TImageEnView


    //crop and resize file
    Crop_Margin := eSize.Value;
    imgRect := imgDest.Proc.AutoCrop( 0, clWhite, False );
    imgDest.Proc.Crop( max( imgRect.Left - Crop_Margin, 0 ),
                    max( imgRect.Top - Crop_Margin, 0 ),
                    min( imgRect.Right + Crop_Margin, imgDest.IEBitmap.Width ),
                    min( imgRect.Bottom + Crop_Margin, imgDest.IEBitmap.Height ) );

    w := FltToInt(eWidth.Value);
    h := FltToInt(eHeight.Value);
    if eFilter.Itemindex <> -1 then begin
      if (w > 0) and (h > 0) then begin
        imgDest.Proc.Resample(w, h, TResampleFilter(eFilter.Itemindex));
      end;
    end;

    // save destination file
    imgDest.IO.SaveToFile(outFile);

xequte

38179 Posts

Posted - Oct 15 2020 :  15:47:30  Show Profile  Reply
Hi

You may need to force windows to refresh the thumbnail with
SHChangeNotify:

https://stackoverflow.com/questions/61200815/update-image-thumbnail-from-c-sharp
https://docs.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shchangenotify

The other possibility is that the image contains a thumbnail and Windows is using that. So you should update the thumbnail:

https://www.imageen.com/help/TIOParams.EXIF_Bitmap.html
https://www.imageen.com/help/TIOParams.UpdateEXIFThumbnail.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

whisper1980

USA
83 Posts

Posted - May 11 2021 :  12:52:54  Show Profile  Reply
A little late, but might help others. This worked for me using Delphi 10.4.2:
SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATHW or SHCNF_FLUSH, Pointer(fImageFilename), nil);

Where fImageFilename is a string and is the path to the jpg file I had just edited.

Eric
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: