• Home
  • Index
  • Search
  • Download
  • Server Rules
  • House Roleplay Laws
  • Player Utilities
  • Player Help
  • Forum Utilities
  • Returning Player?
  • Toggle Sidebar
Interactive Nav-Map
Tutorials
New Wiki
ID reference
Restart reference
Players Online
Player Activity
Faction Activity
Player Base Status
Discord Help Channel
DarkStat
Server public configs
POB Administration
Missing Powerplant
Stuck in Connecticut
Account Banned
Lost Ship/Account
POB Restoration
Disconnected
Member List
Forum Stats
Show Team
View New Posts
View Today's Posts
Calendar
Help
Archive Mode




Hi there Guest,  
Existing user?   Sign in    Create account
Login
Username:
Password: Lost Password?
 
  Discovery Gaming Community Welcome Help & Support Tutorials & Tools Community Technical Guides
1 2 Next »
Powershell Script / Convert .bmp to .jpg in the Freelancer Folder

Server Time (24h)

Players Online

Active Events - Scoreboard

Latest activity

Powershell Script / Convert .bmp to .jpg in the Freelancer Folder
Offline Major.
10-08-2024, 04:41 PM, (This post was last modified: 10-09-2024, 12:11 PM by Major..)
#1
Imperial Veteran
Posts: 899
Threads: 64
Joined: Jun 2015

Hello guys,

as we all face the same issue with the .bmp format once we get a screenshot in Freelancer, I wrote a small PowerShell script that will do the following:

- It looks into your FreelancerShots Folder
- It will "take" all your .bmp pictures and convert them into .jpg
- Once it did the converting, it will delete all the .bmp files.


BMP to JPG
Code:
#  Here you have to enter the folder path, so it looks like this: $Path = "C:\Users\Major\Pictures\FreelancerShots"

$Path = "Put your FreelancerShots Folder path in here"

# Creating a function so we can call it later

function ConvertTo-Jpg
{
    [cmdletbinding()]
    param([Parameter(Mandatory=$true, ValueFromPipeline = $true)] $Path)

    process{
        if ($Path -is [string])
        { $Path = get-childitem $Path }

        $Path | foreach {
            $image = [System.Drawing.Image]::FromFile($($_.FullName));
            $FilePath = [IO.Path]::ChangeExtension($_.FullName, '.jpg');
            $image.Save($FilePath, [System.Drawing.Imaging.ImageFormat]::Jpeg);
            $image.Dispose();
        }
    }

}

# Moving into our Freelancer Shots Folder

cd $Path

# Taking all .bmp files and converting them into .jpg

Get-ChildItem *.bmp | ConvertTo-Jpg

# Deleting all .bmp files since we are done with converting

Get-ChildItem *.bmp | foreach { Remove-Item -Path $_.FullName }

BMP to PNG
Code:
#  Here you have to enter the folder path, so it looks like this: $Path = "C:\Users\Major\Pictures\FreelancerShots"

$Path = "Put your FreelancerShots Folder path in here"

# Creating a function so we can call it later

function ConvertTo-Png
{
    [cmdletbinding()]
    param([Parameter(Mandatory=$true, ValueFromPipeline = $true)] $Path)

    process{
        if ($Path -is [string])
        { $Path = get-childitem $Path }

        $Path | foreach {
            $image = [System.Drawing.Image]::FromFile($($_.FullName));
            $FilePath = [IO.Path]::ChangeExtension($_.FullName, '.png');
            $image.Save($FilePath, [System.Drawing.Imaging.ImageFormat]::png);
            $image.Dispose();
        }
    }

}

# Moving into our Freelancer Shots Folder

cd $Path

# Taking all .bmp files and converting them into .png

Get-ChildItem *.bmp | ConvertTo-Png

# Deleting all .bmp files since we are done with converting

Get-ChildItem *.bmp | foreach { Remove-Item -Path $_.FullName }

- Copy the code into the Powershell Ise and edit the $Path = "Put your FreelancerShots Folder path in here"

- Once that is done, mark the code and press F8. (Depending on your Windows policy, you have to do it with F8 because it's non signed code, if you have set your Set-ExecutionPolicy Unrestricted you can just do it via run script. F5)

- Check your FreelancerShots folder and .bmp should be gone and everything else became .jpg

Just make a copy of the old folder and test my PS script and see if it works. If you need help, send me a forum PM or a discord message - major.

[Image: R5zSdBa.png]
Reply  
Offline Petitioner
10-08-2024, 11:54 PM,
#2
a e s t h e t i c
Posts: 3,346
Threads: 291
Joined: Dec 2009
Staff roles:
Server Administrator

Would changing the ConvertTo-Jpg bit to ConvertTo-Png work/be recognized by powershell? I don't mess around with powershell too much, but I find my screenshots are less blurry and have less washing-out of colors when they are pngs.

[Image: gamer5000.gif]

Recruitment | Task Force Prometheus | ICN FIRESTORM
  Reply  
Offline Major.
10-09-2024, 12:07 AM, (This post was last modified: 10-09-2024, 12:15 AM by Major..)
#3
Imperial Veteran
Posts: 899
Threads: 64
Joined: Jun 2015

(10-08-2024, 11:54 PM)Petitioner Wrote: Would changing the ConvertTo-Jpg bit to ConvertTo-Png work/be recognized by powershell? I don't mess around with powershell too much, but I find my screenshots are less blurry and have less washing-out of colors when they are pngs.

I will give you the version for .png tomorrow, you have to edit like 3 lines to make it work. But kinda hard on a phone Smile

Edit: Check your Discord PM

[Image: R5zSdBa.png]
Reply  
Offline Tenshi Kuonji
10-09-2024, 12:38 AM,
#4
Rheinland Night Knight
Posts: 352
Threads: 46
Joined: Feb 2019

I am not fully sure if this could work but try check this one ...

Code:
# Enter the folder path
$Path = "Put your FreelancerShots Folder path in here"

# Function to convert only .bmp images to .png
function ConvertTo-Png {
    [cmdletbinding()]
    param([Parameter(Mandatory=$true, ValueFromPipeline=$true)] $Path)

    process {
        if ($Path -is [string]) {
            $Path = Get-ChildItem -Path $Path -Filter "*.bmp" # Filter for BMP files
        }

        $Path | foreach {
            try {
                $image = [System.Drawing.Image]::FromFile($($_.FullName))
                $FilePath = [IO.Path]::ChangeExtension($_.FullName, '.png')
                $image.Save($FilePath, [System.Drawing.Imaging.ImageFormat]::Png)
                $image.Dispose()
            }
            catch {
                Write-Error "Failed to convert $($_.FullName): $_"
            }
        }
    }
}

# Check if the path exists before changing to it
if (Test-Path $Path) {
    cd $Path
} else {
    Write-Error "Path not found: $Path"
    exit
}

# Taking all .bmp files and converting them into .png
Get-ChildItem *.bmp | ConvertTo-Png

# Deleting all .bmp files since we are done with converting
Get-ChildItem *.bmp | Remove-Item

I will be testing it when i get home but i did some small tweaks and writtings to the code of Major as i can code on tablet (Android), hope it works, if not i will look for a fix of it

[Image: bVCB4sP.gif]
Discord : Tenshi Kuonji#3786 ✙|✙ Other Networks : Tenshi Hidden Links
Best Ranks Ever: 1|IC Kaiserliche Polizei Rheinland (KPR| Tagged Vessels)
The Arctic Trickster:Tales of Foxy Tenshi ✙|✙ Links: (soon)
Blogger | Amino | Medium | WordPress | DevArtStories

And so shall they fall, all who bear our mark. No matter who they are, no rank, nor title, nor power shall shield them. When the mark finds them, their time is nigh.
Reply  
Offline Major.
10-09-2024, 12:12 PM, (This post was last modified: 10-09-2024, 12:12 PM by Major..)
#5
Imperial Veteran
Posts: 899
Threads: 64
Joined: Jun 2015

Added the code for .bmp to .png in my first post.

Enjoy.

[Image: R5zSdBa.png]
Reply  


  • View a Printable Version
  • Subscribe to this thread


Users browsing this thread:
1 Guest(s)



Powered By MyBB, © 2002-2025 MyBB Group. Theme © 2014 iAndrew & DiscoveryGC
  • Contact Us
  •  Lite mode
Linear Mode
Threaded Mode