Jump to content

Save File Thumbnail


Josh
 Share

Recommended Posts

@Andy90 When you right-click on a file in the asset browser there is an option to save the thumbnail as a PNG image.

local extension = {}

function extension.hook(event, extension)
    
    if event.id == EVENT_WIDGETACTION and event.source == extension.menu then
        if program.assetbrowser.selectedfile ~= nil then
            local file = RequestFile("Save File", CurrentDir().."/", "Portable Network Graphics:png", 1, true)
            if file ~= "" then
                local assetfilename = Lower(StripDir(program.assetbrowser.selectedfile.path))
                local n
                for n = 1, #program.assetbrowser.assetdisplays do
                    if program.assetbrowser.assetdisplays[n].panel:GetHidden() == false then
                        if Lower(program.assetbrowser.assetdisplays[n].label.text) == assetfilename then
                            local pixmap = program.assetbrowser.assetdisplays[n].thumbnail.pixmap
                            if pixmap == nil then
                                Print("Error: No pixmap found")
                                return true
                            end
                                pixmap:Save(file)
                            break 
                        end
                    end
                end
            end
        else
            Print("Error: No file selected")
        end
    end
    return true
end

CreateMenu("", program.assetbrowser.filepopupmenu)
extension.menu = CreateMenu("Save Thumbnail", program.assetbrowser.filepopupmenu)
ListenEvent(EVENT_WIDGETACTION, extension.menu, extension.hook, extension)

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...