Jump to content

Recommended Posts

Posted

Script you can run from the editor when you need it:

path = RequestDir("Open Folder", program.project.path.."/")
local files = LoadDir(path)
local n
local count = 0
for n = 1, #files do
    if FileType(path.."/"..files[n]) == 1 then
        if Lower(ExtractExt(path.."/"..files[n])) == "png" then
            local pixmap = LoadPixmap(path.."/"..files[n])
            if pixmap then
                if pixmap.size.x > 2048 or pixmap.size.y > 2048 then
                    if pixmap.size.x > pixmap.size.y then
                        pixmap = pixmap:Resize(2048, 2048 * (pixmap.size.y / pixmap.size.x))
                    else
                        pixmap = pixmap:Resize(2048 * (pixmap.size.x / pixmap.size.y), 2048)
                    end
                    pixmap:Save(path.."/"..files[n])
                    count = count + 1
                end
            end
        end
    end
end
Notify("Resized "..tostring(count).." images")

 

Let's build cool stuff and have fun. :)

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.

×
×
  • Create New...