Explicit Thumbnail Save

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
rich61
Posts: 156
Joined: Sat Jul 20, 2019 9:56 am

Explicit Thumbnail Save

Post by rich61 »

FreeCAD has a setting in Preferences-general-document to Save thumbnail into project file when saving document.

It seems to save whatever the last screen shows at the time the file is saved, whichever orientation or zoom the screen state was in. So it can change each time you save, even if that wasn't your intention. If you previously had a thumbnail saved, and you turn off 'save thumbnail ...' then it will not retain the last thumbnail, it erases it to a blank.

Would it be better to have an explicit 'Save thumbnail' when we have the view that we want represented in the file thumbnail ? I think yes.
chrisb
Veteran
Posts: 54207
Joined: Tue Mar 17, 2015 9:14 am

Re: Explicit Thumbnail Save

Post by chrisb »

Nice idea.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
FBXL5
Posts: 990
Joined: Sat Aug 03, 2019 8:45 pm

Re: Explicit Thumbnail Save

Post by FBXL5 »

rich61 wrote: Tue May 16, 2023 7:22 pm Would it be better to have an explicit 'Save thumbnail' when we have the view that we want represented in the file thumbnail ? I think yes.
+1
MitjaN
Posts: 11
Joined: Sat Apr 03, 2021 3:30 pm

Re: Explicit Thumbnail Save

Post by MitjaN »

rich61 wrote: Tue May 16, 2023 7:22 pm
Would it be better to have an explicit 'Save thumbnail' when we have the view that we want represented in the file thumbnail ? I think yes.
+1
rich61
Posts: 156
Joined: Sat Jul 20, 2019 9:56 am

Re: Explicit Thumbnail Save

Post by rich61 »

I was thinking about this a bit more. If this is something to do, I think it can be more versatile than the way I was first thinking.

There is a function QScreen::grabWindow() function.

https://doc.qt.io/qt-6/qtwidgets-deskto ... ample.html

So, that would allow selecting by window any image on the screen, whether it is a 3D image or even a techdraw image, anything, then doing an explicit thumbnail image save. I guess one could consider capturing the image to the clipboard, then saving that as the thumbnail, whether the image comes from a FC image or external for maximum versatility. The thumbnail would not change until saved and overwritten again. I guess there could be an option to save a blank image, which now is the FC logo I believe.

It seems that FC now erases any thumbnail that had been saved, if you uncheck 'save thumbnail' in preferences. Is there a way to inhibit that action ?
rich61
Posts: 156
Joined: Sat Jul 20, 2019 9:56 am

Re: Explicit Thumbnail Save

Post by rich61 »

If the preference set to save thumbnail, it saves thumbnail during closing of the FreeCAD file, and saves whatever model view you have on the screen as the thumbnail.
thumbnailsSelect.png
thumbnailsSelect.png (8.84 KiB) Viewed 1595 times

So far, so good. However if I then unclick thumbnail save, FreeCAD 'aggressively' deletes the 'thumbnail/Thumbnail.png' file entirely in its save/exit processing.

So, if it is possible,

IF "thumbnail/Thumbnail.png" already exists in exit/close processing
Just don't delete "thumbnail/Thumbnail".
So, now you can click the save thumbnail option, save your file, then unclick the thumbnail option and your image will be there until you delibratly overwrite it. Sounds simple when I think about it.
I did discover that you can save a sketch image as a thumbnail. Just enter your sketch screen, save the project, close your sketch, then exit freecad without a save. I don't think I would ever want to do that normally, but interesting.
drmacro
Veteran
Posts: 8984
Joined: Sun Mar 02, 2014 4:35 pm

Re: Explicit Thumbnail Save

Post by drmacro »

I don't think it aggressively deletes one if it its there...with that unchecked it simply doesn't save one when the save happens.

And what if I do indeed want to save the file sans thumbnail?
(No need to answer, that a rhetorical question. Having gone through setting up systems so the thumbnail is displayed in the file browser when the system is configured to do so, I sort of understand the process. ;) )
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
rich61
Posts: 156
Joined: Sat Jul 20, 2019 9:56 am

Re: Explicit Thumbnail Save

Post by rich61 »

Thanks for the remarks. I was just having a little fun with the aggressive software concept. Once we have A.I. we might worry though.

If you want to get rid of the thumbnail, you just display a blank screen and save. You can zoom in on blank background.

I'm not quite sure how the FC exit/save process works, but maybe that sequence asks various other functions if they have anything to save. In that case, the existing thumbnail could have been preloaded on startup, then given back on save.

Under the "Tools" menu there is a function "Save Image". I think it is aimed at high quality images, and saves external to the FCStd file. That would be OK if there was a naming convention for thumbnails. If that function would save a thumbnail that would be fine, then the normal save thumbnail option in preferences could be eliminated. However there would have to be some provision in the database to keep it around until either updated with a new save or simply maintained. Partly -- the all in one zip file limits some options. Good for distribution, bad for versatility.

As for making file browsers work with FreeCAD thumbnails, it is not common. I think an external customized program would be better.

An external FC_browser program would be multi-platform and file-browser independent. FC_Browser would display a grid, where you click on the thumbnail and it launches freeCAD. Or you hover, and it gives more information, etc. Just like any file browser, but custom for FC. I've toyed with a program. Of course being external, it wouldn't be any interference to the Master work. Each project can have a document, out of the many, defined to be the master reference document. Then such a browser could present text links, for example to the pdf file for a part in my assembly that is on line at the manufacturer, or one that I had downloaded to th# return thumbnail image from FreeCAD file.

Code: Select all

# return thumbnail image from FreeCAD file
    # handles any error as thumbnail file not present error
    def FC_getThumbnail(self, FCStd_file):
        file_thumb = "thumbnails/Thumbnail.png"
        try:
            with ZipFile(FCStd_file, 'r') as zip:
                pixmap = QPixmap(zip.extract(file_thumb))
        except:   # ThumbNail Not Found
            pixmap = QPixmap(128, 128)
            pixmap.fill('gray')  # represent no thumbnail
        return pixmap
    
drmacro
Veteran
Posts: 8984
Joined: Sun Mar 02, 2014 4:35 pm

Re: Explicit Thumbnail Save

Post by drmacro »

rich61 wrote: Sun May 28, 2023 5:48 pm ...
If you want to get rid of the thumbnail, you just display a blank screen and save. You can zoom in on blank background.
...
But then there would still be a thumbnail section in the .FCStd file, no?
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
rich61
Posts: 156
Joined: Sat Jul 20, 2019 9:56 am

Re: Explicit Thumbnail Save

Post by rich61 »

True, but: Is there a reason to get rid of thumbnail/Thumbnail.png ? A default or erased version could be the FC logo image or you own logo if you for some reason, didn't want to represent the cad model image.

It doesn't take up much space. It should always be there, I think.
Post Reply