Add scaled timestamps to photos using ImageMagick

Here is one way to add timestamps quickly to lots of photos using open source tools and a script.

The image editing is done using ImageMagick  convert.exe and identify.exe

ImageMagick is a free to use open source collection of command line tools for image editing, identifying, manipulation and much more.

stamp

This script will go through all JPG, JPEG, GIF and PNG files inside the current folder, make copies of them in a separate folder and add date and time saved (burned) into the image. The operation is lossy hence it only modifies copies of the files. Date and time is retrieved from the metadata tag Exif.Image.DateTimeOriginal. If the images lack this tag they will be stamped “No timestamp”.

The timestamp font size and placement on the photo will scale in percentage according to the width and resolution of the photo.

If you want to change colors or such you will need to edit the script manually. Here are some examples of photos I’ve taken with added timestamps:

If these kind of timestamps are good enough for you, you’ve found the right post!

Instructions

timestamp

Option a) – quick

1. Download the script (mirror) together with portable ImageMagick convert.exe and identify.exe
MD5: a5363bef4aafbe979dcac875f7f2e263

2. Extract all files in the folder where you keep the images that you wish to add timestamps to

3. Double click on add timestamps.bat to start the process.

A black window should pop up showing the image conversion process in ImageMagick.

timestamp

4. When done you should see a folder named stamped with copies of the files with added timestamps!

Option b) – manual

1. Download ImageMagick from the windows portable edition here and place convert.exe and identify.exe in the same directory where you place the script. Alternately you can use the files supplied in the download above.

2. Copy and paste the code from below into your favorite plain text editor like notepad, notepad2 or notepad++

3. Save it with whichever name you prefer as long as you end the name with the file extension .bat for example add timestamps.bat

4. Double click on the bat file to start the process!

Batch script to copy and paste

@echo off & cls
rem enable variables referencing themselves inside loops
SetLocal EnableDelayedExpansion

rem optional settings
set fontcolor=#FFD800
set fontoutlinecolor=#000000
set fontstyle="Arial-Bold"

rem create a new folder where the stamped images will be placed
mkdir stamped

rem loop through all jpg png jpeg and gif files in the current folder
for /f "delims=" %%a in ('dir /b /A:-D /T:C "%cd%\*.jpg" "%cd%\*.png" "%cd%\*.jpeg" "%cd%\*.gif"') do (
	rem retrieve image date and time
	SetLocal EnableDelayedExpansion
	for /f "tokens=1-2" %%i in ('identify.exe -ping -format "%%w %%h" "%cd%\%%a"') do set W=%%i& set H=%%j

	rem retrieve image timestamp to perform size and distance calculations on
	SetLocal EnableDelayedExpansion
	for /f "tokens=1-2 delims=" %%k in ('identify -format "%%[EXIF:DateTimeOriginal]" "%cd%\%%a"') do set timestamp=%%k
	
	rem set timestamp to no timestamp if there is no timestamp
	if "!timestamp!" == "" (
		set timestamp=No timestamp
	)
	
	rem print some information about the process
	echo %%a is !W! x !H! stamp !timestamp! ...

	rem set timestamp size to a fourth of the screen width
	set /A timestampsize = !W! / 3

	rem set timestamp offset distance from side of the screen
	set /A timestampoffset = !W! / 20

	rem set timestamp outline relative size
	set /A outlinewidth = !W! / 600

	rem echo !timestampsize! !timestampoffset!
	
	rem create a custom image with the timestamp with transparent background and combine it with the image
	convert.exe ^
	-verbose ^
	-background none^
	-stroke !fontoutlinecolor! ^
	-strokewidth !outlinewidth! ^
	-font !fontstyle! ^
	-fill !fontcolor! ^
	-size !timestampsize!x ^
	-gravity center label:"!timestamp!" "%cd%\%%a" +swap ^
	-gravity southeast ^
	-geometry +!timestampoffset!+!timestampoffset! ^
	-stroke !fontoutlinecolor! ^
	-strokewidth !outlinewidth! ^
	-composite "%cd%\stamped\%%a"

	endlocal
	endlocal
	echo.
)
endlocal
echo Complete!
pause

More info

I also wrote a VBScript version of this operation as well but It would have a lot of black windows popping up being quite annoying.

Unfortunately hiding windows gets trickier when using VBScript when you also need to retrieve the return value from command line utilities.

If you want to check out the vbscript anyway you can still get it here (mirror) (git)


Bypassing European ‘Right to be forgotten’ censorship of Google

Update 2016: Using google.com/ncr to bypass the filter no longer works. Google now censors EU results if you’re in the EU ISP IP range. You have to use a US proxy.

This post is not related to any software but rather in opposition of censorship.

Problem

If you’re in the EU and searching using Google you may have encountered this notice at the bottom of some pages:

censorship

If you did not know there is a European Union law that allows people the “Right to be forgotten” which specifically applies to Google search.

While it may sound like a good idea in some regards, like perhaps false accusations; in practice it forces search providers to act as judges for what is appropriate.

This can have the exact opposite effect for actual perpetrators which makes this legislation really flawed.

Workaround

There are many ways to bypass such filters, one of them by using another search engine or any kind of vpn or proxy server. There is also a hidden option in Google:

http://www.google.com/ncr

The abbreviation NCR stands for – no country redirect.
This option will return US search results.

More information

I won’t go into this into this law in any more detail but feel free to read more about the “Right to be forgotten” and controversy related to it here:


HTML image gallery generator using VBScript and ImageMagick

Update 2015-06-11: Added msdos short paths to (hopefully) avoid unicode character errors

This VBScript will create a very basic HTML image gallery of all image files placed in the same directory as the script.

It generates thumbnails using ImageMagick and links to the original images.

ImageMagick is a free to use open source collection of command line tools for image editing, identifying, manipulation and much more.

Result

htmlgallery

Instructions

Option a) – quick

gallery script

1. Download the script (mirror) together with portable ImageMagick mogrify.exe in this zip file.
MD5: 704945e2e269aa222ea321a9eff0871f
(github)

2. Extract both files in the same folder where you keep the images that you wish to use in your gallery

3. Double click on CreateHTMLImageGallery.vbs to start the procedure.

A black window should pop up showing the image conversion process in ImageMagick. The window will close when the thumbnails have been created and a preview window will open in your browser.

cmdwindow

4. When done you should see a folder named thumbs with low resolution copies (thumbnails) of your images inside it.

Option b) – manual

1. Download ImageMagick from the windows portable edition here and place mogrify.exe in the same directory where you place the script. Alternately you can use the file supplied in the download above.

2. Copy and paste the code from below into your favorite plain text editor like notepad, notepad2 or notepad++

3. Save it with whichever name you prefer as long as you end the name with the file extension .vbs for example CreateHTMLImageGallery.vbs.

4. Double click on the script to start the process!

 VBScript to copy and paste

 

'Simple html gallery maker using ImageMagic mogrify.exe
'Written by Nicklas H https://nirklars.wordpress.com

'Updated 2015-06-11

'---DECLARATIONS SECTION---

Set args = Wscript.Arguments
Set FSO = CreateObject("Scripting.FileSystemObject")
Set SHELL = CreateObject("WScript.Shell")

'Get proper current directory
SHELL.CurrentDirectory = FSO.GetParentFolderName(Wscript.ScriptFullName) 
'Declare folder to check files in
Set objFolder = FSO.GetFolder(SHELL.CurrentDirectory)
Set colFiles = objFolder.Files

'Declare global variables
Dim OutputFile 
Dim OutputFileContent
Dim FirstLineCheck

'You can change this to gallery.html or whatever you wish
OutputFile = SHELL.CurrentDirectory & "\index.htm"
'Change this if you want another thumbnail size or quality
ImageMagicArguments = "-thumbnail 200x -quality 65 -verbose"

'---PROGRAM SECTION---

'Check if a gallery already exists, if so then delete if
DelFile(OutputFile)

'Regular html gallery code stuff, this is just an example
W("<html>")
W("	<head>")
W("	<title>Image Gallery</title>")
W("		<style>  ")
W("		a:link")
W("		{")
W("			text-decoration: none;")
W("			color: black;")
W("		}")
W("		a:visited")
W("		{")
W("			color: black;")
W("		}")
W("		a:hover")
W("		{")
W("			color: red;")
W("		}")
W("		img ")
W("		{")
W("			border-style: solid;")
W("			border-width: 2px;")
W("			margin: 2px;")
W("			padding: 0px;")
W("			}")
W("		</style>")
W("	</head>")
W("	<body>")

' Breakdown of the <img> tag to be pieced together in the loop
ImagePart1 = "		<a href='"
ImagePart2 = "'><img src='thumbs/"
ImagePart3 = "'></a>"

' Go through every file in the folder and create the <img> tag and stuff
For Each objFile in colFiles
	complies = false
	
	'check file extensions
	if InStr(objFile.Name,".jpg") > 0 then 
		complies = true
	elseif InStr(objFile.Name,".png") > 0 then 
		complies = true
	elseif InStr(objFile.Name,".jpeg") > 0 then 
		complies = true
	elseif InStr(objFile.Name,".gif") > 0 then 
		complies = true
	else
		'skip
	end if
	
	if complies = true then
		W(ImagePart1 & objFile.Name & ImagePart2 & objFile.Name & ImagePart3)
	end if
	
Next

'Final part of the html code
W("	</body>")
W("</html>")

'Write the file at once to save disk access times
SaveFile()

'Check if imagemagick is there
if FSO.FileExists(SHELL.CurrentDirectory & "\mogrify.exe") then
	'Create folder and launch imagemagick
	MkDir(SHELL.CurrentDirectory & "\thumbs")
	command = Quote(SHELL.CurrentDirectory & "\mogrify.exe") & " -path " & Quote(ShortPath(SHELL.CurrentDirectory) & "\thumbs") & " " & ImageMagicArguments & " " & Quote("*")
	'start imagemagick
	SHELL.run command, 1, true
	'open the gallery in your browser
	SHELL.run Quote(OutputFile), 1, true
else
	msgbox "Unable to create thumbnail images. Please put ImageMagick mogrify.exe in the script folder and retry!"
end if

'---FUNCTIONS SECTION---

'Function to get short msdos path to work with unicode folder names
function ShortPath(myPath)
	ShortPath = FSO.GetFolder(myPath).ShortPath
end function

'Function to put quotation marks around paths
function Quote(this)
  Quote = Chr(34) & this & Chr(34)
end function

'Write a new line in the output file
Function W(strLine)
	'Skip line break on the first entry
	if FirstLineCheck = false then
		OutputFileContent = strLine
		FirstLineCheck = true
	else
		OutputFileContent = OutputFileContent & vbNewLine & strLine
	end if
End Function

'Save the output file
Function SaveFile()
    Set stream = FSO.OpenTextFile(OutputFile, 2, True)
    stream.write OutputFileContent
    stream.close
	OutputFileContent = "" 'Clear memory
End Function

'Create folder until success
function MkDir(myFolder)
	do
		'Fix env strings
		myFolder = translateEnvStr(myFolder)
		
		Err.Clear
		On Error Resume Next
		if FSO.FolderExists(myFolder) = true then 
			exit do
		else
			FSO.CreateFolder(myFolder)
			if ErrorMessage() = false then
				exit do
			end if
		end if
		WScript.Sleep 1000
	loop
end function

'Delete a file if it exists, wait if it doesnt work and retry
function DelFile(myFile)
	do
		'Fix env strings
		myFile = translateEnvStr(myFile)
		
		Err.Clear
		On Error Resume Next
		if FSO.FileExists(myFile) then
			FSO.DeleteFile(myFile)
			if ErrorMessage() = false then
				exit do
			end if
		else
			exit do
		end if
		WScript.Sleep 1000
	loop
end function

'Function that translates all EnvironmentStrings into real paths from inside a larger string. Lets call it strLargeEES.
function translateEnvStr(strLargeEES)
	'Count the number of % characters in the supplied string. This is done by removing all of the % from strLargeEES and subtract it from the original strLargeEES.
	intCharNum = Len(strLargeEES) - Len(Replace(strLargeEES, "%", ""))
	
	'Since there are two % signs for each EnvironmentString that means we divide the total number of EnvironmentStrings by...
	intExpandedStringsNum = intCharNum/2
	
	'Loop through all of the EnvironmentStrings. Because we need to translate each one separately.
	for i = 1 to intExpandedStringsNum
		'Cut out the part to the right of %
		strFirstCut = Right(strLargeEES,Len(strLargeEES)-InStr(strLargeEES,"%"))
		'Cut out the part to the left of %
		strSecondCut = Left(strFirstCut,InStr(strFirstCut,"%")-1)
		
		'The result from our cutting reveals the first EnvironmentString!
		result = "%" & strSecondCut & "%"
		'We translate this to the real folder by using a shell object
		translated = SHELL.ExpandEnvironmentStrings(result)
		
		'When we are done we replace the original EnvironmentString with the translated in strLargeEES
		strLargeEES = Replace(strLargeEES,result,translated)
	'Repeat
	next
	
	'When done return the whole translated string to the function call
	translateEnvStr = strLargeEES
end function

 


PDF to DWG using free open source Inkscape

inkscape-screenshotInkscape is a completely free open source program for drawing vector graphics and has a lot of nifty features, among them file format conversion.

This guide will go through the procedure to get those pesky PDF drawings into AutoCAD using Inkscape.

This tutorial is written in a easy to follow step by step instructional guide intended for everyone. (Hopefully) even computer novices.

There are some limitations to the act of converting PDF to DWG that should be noted beforehand:

  • PDF files are not as accurate as DWG and should not be considered to exact scale. Think of it almost as importing a paper drawing.
  • Not all features will be converted. Some color fills, raster graphics and custom objects may be lost in the conversion. (Or require more work)
  • You can only import 1 page at a time.
  • Conversions like this can be tricky and unfortunately some files don’t do very good.

In depth step by step guide

1. Figure out the paper size of your PDF file.

Start up Adobe Acrobat. Go to File -> Properties

1

In the Description tab you should see the page size. Depending on the program used to create the PDF file (in this case AutoCAD) it might not say the ISO standard page size. Take note of the page size. In this case 841 x 594 mm which is a A1 ISO standard page size.

2

2. Download and install Inkscape.

For most windows users that’s here https://inkscape.org/en/download/windows/

If you’re uncertain which version to get read here. Most probably you will want the 64 bit installer unless you’re on an old computer with less than 4GB of ram. Then get the 32 bit installer.

3. Start up Inkscape and set the correct paper size. When starting for the first time it should have opened an empty document with an A4 size paper.

Go to File -> Document properties. Find the size of your paper or manually enter the custom page size into the text boxes. Also select the orientation of the paper to be portrait or landscape.

4 5

This page can be a bit slow and unresponsive. If Inkscape freezes or stops responding it has not crashed, have patience and give it some time and it will come to.

5. Import the PDF document from File -> Import

A new dialog box should appear with settings. If you encounter problems repeat the previous steps and return to this step and retry it with different settings. After clicking OK Inkscape may appear to freeze depending on the size of the PDF file. Large A0 drawings can take 5 minutes… just saying 🙂 Again, patience is the key here.

3 6

6. Align the imported page by clicking and draging it to the center of the paper canvas. When you’re satisfied click outside the canvas to deselect the paper.

7

7. Go to File -> Save a copy. Locate the folder where you want to save the file and select Desktop Cutting Plotter (AutoCAD DXF R14) (*.dxf) from the drop down list below in the save dialog window.

8

8. Select the base units for the drawing. In the case of ISO standard A1 paper it should be millimeters (mm).

If you have problems with the importing process repeat all the previous steps and return to this dialog and try checking or unchecking the other options.

9

Click OK to start the process. Depending on the size of the drawing this could take a while.

9. Inspect the DXF file by opening it in AutoCAD.

You should now have a quite large DXF drawing file exported. DXF stores coordinates in plain text without any compression so a DXF file might take 30 times or more data space than a DWG. Keep this in mind and try to avoid storing DXF files (for the sake of hard drive space).

10. Carefully check the scale….. and any possible errors

Its very easy to accidentally mess up the scale while importing/exporting so make sure to properly measure and compare the scale in the output drawing. There will be some inaccuracies.

11. Correct the scale if necessary

One way to correct scale is to use scale by reference.

1. SCALE command
2. Specify base point
3. Type R to use scale by Reference
4. Specify reference length by start point and end point
5. Specify new length

scale by reference

11. Save the DXF file as a DWG file.

Congratulations! You should now be done!

If you have errors opening the file try repeating the procedure with slightly different options where specified. You might also try the RECOVER or AUDIT command in Autocad. Keep in mind that errors probably mean that something was also lost in the procedure. Make sure to compare and figure out what it was.

I hope this was helpful! 🙂


Fallout 2 not responding in combat bug

fallout2notresponding

Description

Fallout 2 stops responding during combat and resumes at the end of the round. You may or may not have any unofficial patches installed and/or are running the game in windowed mode.

Background

If you’re attempting to play the classic Fallout 2 on Windows 7 or Windows 8 you will probably encounter the the bug above. This is not specifically a bug in Fallout 2 but rather a compatibility issue in recent Windows operating systems.

Before proceeding I highly recommend that you install one of either of killaps unofficial patches:

– Unofficial Fallout 2 patch by killap
– Fallout 2 Restoration Project by killap

It goes without saying but don’t install both! Choose one.

Save files might not work after installing the patch so make a backup of the whole Fallout folder before installing.

The unofficial patch fixes general bugs while the restoration project restores a lot (if not all) cut content and adds in a some extra mod content. I highly recommend the restoration project patch. It adds a lot of things to the game which enriches the experience, even for first time players.

Download killaps patches over at www.killap.net or the No Mutants Allowed forums.

Windows AppHangTimeout registry entry

Here is one way to fix this issue.

Please note that the following changes will affect all programs running on your operating system. This may cause issues for you but shouldn’t make much (if any) difference to the general user who knows how to use windows task manager to force terminate applications.

As always when editing the registry make a backup or create a system restore point in case you make any mistakes. (Mistakes can mess up your computer so do this at your own risk)

Option 1: Download and double click on any of the following registry patches

Right click the link and select save as. Make sure that the name (file extension) ends with .reg. Otherwise rename it.

a) 120 second delay before the “program not responding” pops up.
(this should be enough for most fights in Fallout 2)

b) 300 second delay if you intend to go rampage and battle entire cities, this 5 minute delay might be more for you

c) remove (uninstall) the registry entry to use windows default timeout

Option 2: Manually edit the registry

1. Open regedit.exe

2. Browse to HKEY_CURRENT_USER \ Control Panel \ Desktop

3. Check if there is an entry for HungAppTimeout

4. If there is a value then double click and edit this to the delay value you wish to have in milliseconds.

5. If there is no value right click and select New -> String value and name it exactly “HungAppTimeout” without the quotation marks.

6. Double click this and enter the delay value that you wish in milliseconds.

hungapptimeout2

 Notes or alternate fixes

If you for some reason absolutely cannot change this registry entry there is an option in Fallout 2 High Resolution Patch (f2_res) you can try.

The high resolution patch is included in both of killaps patches so I really recommend you install one of them! It makes the install procedure much easier for you.

1. Open up f2_res.ini in your Fallout 2 install path

2. Scroll down a bit until you find EXTRA_WIN_MSG_CHECKS=0

3. Change the 0 (zero) to 1 (one) so that it looks like this:

f2_res.ini

Fake windowed fullscreen

I just wanted to add this section here as well. As this game runs really well with the fallout 2 high resolution patch you might consider running an AutoHotkey script to toggle fake fullscreen. Fake fullscreen is also built into my application XBoxMouse and works even if you don’t have any controller plugged in. You need to enable it by editing the line WindowedFullscreen=1 in the ini file however.

Optional pre compiled script

Download and run the compiled script here (mirror).
MD5 checksum: 99882c79d419503604a52c74cd785cc3

Please note!
You probably have set this program to run as an administrator in the compatibility tab!

Hold down CONTROL and ALT and press F12 to toggle fake fullscreen!

Run the script manually

1. Download and install AutoHotkey

2. Option: Download the script (mirror) and double click it (right click and select save as)

3. Copy and paste the following script into notepad your plain text editor of choice (notepad2 or notepad++)

4. Save the file as whatever you wish as long as it ends with the file extension .ahk

5. Double click the ahk file to have it run in the background. Hold down CONTROL and ALT and press F12 to toggle fake fullscreen on the window you currently have focused.

Script to copy and paste

;Toggle fake windowed fullscreen!
;https://nirklars.wordpress.com

#singleinstance force

!^F12::
	WinGet, WindowID, ID, A
	WinGet Style, Style, ahk_id %WindowID% ; retrieve window data

	if (Style &amp;amp; 0xC40000) ; check if object is available
	{
		WinSet Style, -0xC40000, ahk_id %WindowID% ; hide thickframe/sizebox
		WinSet Style, -0xC00000, ahk_id %WindowID% ; hide title bar
		WinSet Style, -0x800000, ahk_id %WindowID% ; hide thin-line border
		WinSet Style, -0x400000, ahk_id %WindowID% ; hide dialog frame
	}
	else
	{
		WinSet Style, +0xC40000, ahk_id %WindowID% ; show thickframe/sizebox
		WinSet Style, +0xC00000, ahk_id %WindowID% ; show title bar
		WinSet Style, +0x800000, ahk_id %WindowID% ; show thin-line border
		WinSet Style, +0x400000, ahk_id %WindowID% ; show dialog frame
	}

	WinMove, ahk_id %WindowID%, , 0, 0, A_ScreenWidth, A_ScreenHeight

return

Hope this helps 🙂
Happy retro gaming!
Best Regards


Baldur’s Gate II widescreen scaling bug

Here is a unique issue for you… with an odd workaround solution. To sum it up its a script that “works around” improper scaling resulting in black bars when you have dual graphics cards and nothing else appears to work.

Problem description – black bars in fullscreen

When running Baldur’s Gate II in fullscreen with the widescreen mod installed and set to 1280×720 you see black bars surrounding the game window.

Before trying the hacky script make sure that you have explored all your control panel graphics options. If you see black bars on your desktop check these Intel options first before proceeding.

bg2wrongscale

Background

My laptop has two graphics cards. One integrated Intel HD and an NVidia 840M. This is quite an ingenious solution to minimize power consumption. The Intel HD works as a low power accelerator for desktop and minor applications with the Nvidia card kicking in as a “turbo” when 3D applications like games are launched.

Unfortunately this rather unique solution can cause driver compatibility issues, as someone searching the internet will find out. One reason being that the drivers supplied by Nvidia are trimmed and lacking the much needed display options.

The fact that Intel doesn’t supply regular updates to their drivers doesn’t help much. They point toward the laptop manufacturer which only supply old drivers.

intel graphics darn

 The solution that should work, try this first

With regular graphics card configurations the NVidia control panel should have the following scaling options available. Unfortunately for me these options are not there. If you have them, then you’re lucky. Change the scaling to full-screen and the borders should be gone.

nvidiascaling

At first glance one might think that Intel lacks these scaling options completely, however this is not true. The scaling options are hidden inside Intel HD graphics control panel.

To show the options you cannot have your desktop resolution set to your monitor native (max) resolution. (which is usually 1920 x 1080 for most monitors) As soon as you change this to something lower, say something like 1024 x 768 temporarily. The option will magically appear at the screen below.

Again, unfortunately for me, this did not fix my issue with Baldur’s Gate.

intel graphics custom aspect scaling

That didn’t work, what now?

The workaround to this problem is a somewhat clumsy AutoHotkey script that switches the desktop resolution temporarily and forcefully stretches the game window to fit the size of your desktop resolution.

Considering the limitations of this workaround it will not work if you’re already seeing black bars when lowering your resolution in desktop. If that is your case, sorry. You’re situation is even more complicated than mine 🙂

This of course assumes that when you installed the Baldurs Gate II widescreen patch you set the resolution to 1280 x 720. While installing it should have looked like this:

widescreenmod_resolution

If you have any more graphics related mods installed the situation may be different.

Instructions for the workaround

Optional Pre compiled script

This will only work if you have configured the widescreen patch to run at resolution 1280×720!

1. Download the compiled script from here (mirror)
MD5 checksum: 998df07f0078cadc684dcf0484e17c6e

Please note!
You probably have set this program to run as an administrator in the compatibility tab!

2. Place it in the directory where you have installed Baldurs Gate

3. Run BGMainNoBorders.exe and it will attempt to launch the game without borders.

Run the script manually

If you’ve set the widescreen resolution patch to anything other than 1280×720 you need to edit the script and run it manually.

1. Download and install Autohotkey

2. Copy and paste the following script below into notepad or any other plain text editor like notepad2 or notepad++.

3. Save the file as BGmainNoBorders.ahk or any other name you prefer as long as you end with the file extension .ahk and save it into your BG2 install folder.

You can also download it directly from here (mirror) (right click and select save as)
(GitHub)

4. Edit the script where it says ChangeResolution(1280,720) to whichever is the resolution you’ve set the widescreen patch to run in.

For example if you have set the widescreen patch to run at 1600×900 you need to change this to ChangeResolution(1600,900)

5. Double click BGmainNoBorders.ahk to start the game!

Script to copy and paste

#singleinstance force ; prevent multiple instances

; increase this if you have a very slow computer to 1500 or 2000
sleepdelay := 1000

; Check and remember current resolution
x = %A_ScreenWidth%
y = %A_ScreenHeight%

run bgmain.exe ; start baldurs gate

sleep %sleepdelay% ; wait milliseconds

; old method of changing resolution
;run qres /x 1280 /y 720 

; change resolution temporarily
ChangeResolution(1280,720)

sleep %sleepdelay% ; wait milliseconds

WinActivate ahk_class ChitinClass ; focus on baldurs gate

sleep %sleepdelay% ; wait milliseconds

SetFakeFullscreen()

WinWaitClose ahk_class ChitinClass ; wait for baldurs gate to close

; old method of changing resolution
;run qres /x %x% /y %y%

; change back resolution
ChangeResolution(x,y)

sleep %sleepdelay%

ExitApp
return

;---Remapped keys 

; Swap arrow keys with WASD for panning
#IfWinActive ahk_class ChitinClass
a::left
left::a

; Swap arrow keys with WASD for panning
#IfWinActive ahk_class ChitinClass
d::right
right::d

; Swap arrow keys with WASD for panning
#IfWinActive ahk_class ChitinClass
w::up
up::w

; Swap arrow keys with WASD for panning
#IfWinActive ahk_class ChitinClass
s::down
down::s

; Select all party members using tilde
#IfWinActive ahk_class ChitinClass
SC029::SC00c
SC00c::SC029

;---Functions

SetFakeFullscreen()
{
	WinGet Style, Style, ahk_class ChitinClass ; retrieve window data
	WinSet Style, -0xC40000, ahk_class ChitinClass ; hide thickframe/sizebox
	WinSet Style, -0xC00000, ahk_class ChitinClass ; hide title bar
	WinSet Style, -0x800000, ahk_class ChitinClass ; hide thin-line border
	WinSet Style, -0x400000, ahk_class ChitinClass ; hide dialog frame
	WinMove, ahk_class ChitinClass, , 0, 0, A_ScreenWidth, A_ScreenHeight
}

ChangeResolution(w,h)
{
	VarSetCapacity(dM,156,0)
	NumPut(156,dM,36)
	NumPut(0x5c0000,dM,40)
	NumPut(w,dM,108)
	NumPut(h,dM,112)
	DllCall( "ChangeDisplaySettingsA", UInt,&dM, UInt,0 )
}

Troubleshooting

If it doesn’t work try to change Baldur’s Gate to run in windowed mode in bgconfig. This should solve it but can cause issues when panning the overview map.

If it still doesn’t work try increasing sleepdelay from 1000 to 1500 or 2000. Also make sure not to click on anything when you’ve launched the script. Have patience and wait for the game to start.

If you’re using any resolutions other than 1280×720 in the widescreen mod you must edit the script manually at ChangeResolution(1280,720) to the resolution of choice.

Extra features

WASD are remapped and swapped with the arrow keys left, up, down and right and tilde for selecting the whole party. This is more of a convenience for me. If you dislike these keybindings delete all the lines from the text file from remapped keys down to functions.

If you’re only looking for the remapped WASD keybindings you can download it directly here (mirror) (right click and select save as) or the pre compiled script executable here (mirror)
MD5: f26caa20a3fbdaec26fe17abf0a6f514
(GitHub)

If you figure out any better solutions or have anything else to add that might help, please don’t hesitate to leave a comment!


SpaceEngine and high resolution screenshots

Scroll down for the instructions to capture high resolution screenshots exceeding your screen size.

If you’re here only for the AutoHotkey script to force window sizes click here.

Update 2016-01-11: In recent versions of SpaceEngine (V 0.973 or higher) you may encounter crashes with OpenGL error messages. Please see here on how you might counter these issues.

BackgroundAldebaran 9.3

I’ve been playing around in a game/simulator named SpaceEngine lately. It’s a simulator exploration game allowing you to travel parts of the known universe and beyond (via procedurally generated) galaxies, star systems and planetary terrain.

If you haven’t checked it out yet you really should! It doesn’t matter if your behind a desk dreaming of being an astronaut, fantasy/scifi stellar explorer extraordinare, a space nut or just mildly fascinated by pretty astronomy photos. It’s free http://en.spaceengine.org/

Special note to security nuts: Space Engine is not open source but I’ve been running version 0.9.7.1 and 0.9.7.2 and my whitelist firewall log hasn’t caught any attempt to even connect to the internet. Considering the large helpful community and experienced users involved in the project it would get some bad rep quickly if it started doing bad things.

Continuing exploring… Spread across this post are some wonderful screenshots that I’ve captured so far. Unfortunately these examples are not all 4K images. 🙂

Taking regular screenshots in SpaceEngine is easy, press F11 to capture the screen without the GUI. The screenshots you capture will end up in this folder: \SpaceEngine 0.972\screenshots\

extrasolar_comet_by_nirklars-d8epalq_png

Setting the proper screenshot file format

Wait! Before you go on a screenshot frenzy there is an important option you need to know about. This option makes sure that the screenshots you save are stored in the best quality. This option is not available from inside the game GUI so you need to manually edit a text file in the config directory.

1. Browse to the following file from the place where you installed SpaceEngine:
\SpaceEngine 0.972\config\main.cfg

2. Open main.cfg it in a text editor like notepad or notepad++ and scroll down until you find this line.

edit

3. Replace “jpg” with “png”. Save the file and restart SpaceEngine. Your screenshots will now be taken in high quality PNG image files instead of lossy JPEGs

Exomoon of binary red dwarfs

In game configuration

To get more visuals out of your experience keep tinkering around with the settings in game. To open the settings menu move your mouse to the lefthand side of the screen for the menu to appear. Then click on the bottom cogwheel icon.

There’s also a hotkey by holding down CTRL and pressing F4 (CTRL+F4) which opens the graphics menu directly.

When exploring terrain on planets what you want to do is to increase the Level of Detail (LOD). Be careful changing this value; it will quickly eat up your graphics card memory and can cause freezes and crashes.

Avoid loosing your position after crashes by saving your location often using F6.

Want even greater visuals using higher resolution screenshots? Keep reading!

marred_tarantula_impact_remnant_3_by_nirklars-d8dn1za_pngBreaking the 1920 x 1080 barrier

After playing around in SpaceEngine as you might have noticed, you can’t capture screenshots higher than your screen max resolution. Not owning a real 4K monitor in order to do this you will require hacks or tricks to manipulate the program to do what you want. Now there are many different programs that can do this to other games or games in general. Some may contain malware or adware. Here is an alternate way using solely open source tools. AutoHotkey specifically.

AutoHotkey is a very versatile and portable scripting language for windows intended to help you with hotkeys, keyboard and mouse automation and moooore. Here are some instructions on how to use a basic script to force a window into any size that you want. Even sizes that exceed your monitor max resolution.

Beware however, forcing programs to do something they were never intended to do is risky. Expect them to crash or freeze; side effects may include hairloss, overfeeding or brain malfunction. (not really… maybe)

Before attempting the following; save your progress in all open programs first! You have been warned!

 AutoHotkey script to force window sizes

This script will work for resolutions exceeding your monitors max resolution.

It’s written to toggle the size of the window that currently has focus whenever you press the key F12. You can change this key into anything you want by editing the following text in the script. For example changing the first line:
F12::
Into:

^F12::
Will toggle it when pressing CTRL+F12

+F12::
Will toggle when pressing SHIFT+F12

^+F12::
Will toggle when pressing CTRL+SHIFT+F12.

Get it? The symbols represent modifiers on your keyboard.  Feel free to read more about using AutHotkey hotkeys.

 AutoHotkey 4096 x 2160 window size script usage instructions

1. Download and install AutoHotkey if you haven’t already.

2. Copy and paste the following into your favourite text editor. Or download the script here (mirror) (Right click and select save as)

F12::
WinGet, TempWindowID, ID, A
If (WindowID != TempWindowID)
{
  WindowID:=TempWindowID
  WindowState:=0
}
If (WindowState != 1)
{
  WinGetPos, WinPosX, WinPosY, WindowWidth, WindowHeight, ahk_id %WindowID%
  WinSet, Style, ^0xC40000, ahk_id %WindowID%
  WinMove, ahk_id %WindowID%, , 0, 0, 4096, 2160
}
Else
{
  WinSet, Style, ^0xC40000, ahk_id %WindowID%
  WinMove, ahk_id %WindowID%, , WinPosX, WinPosY, WindowWidth, WindowHeight
}
WindowState:=!WindowState
return

3. Save the file as 4K resolution.ahk or whichever name you prefer as long as the file extension ending is .ahk

4. Browse to where you saved the file and double click on it.

5. The script is now running in the background, waiting for you to press F12. Pressing once will set the window size to 4096 x 2160. Pressing it again will toggle the window back.

6. Right click the system tray and click exit to turn the script off.

exit2

Optional: Edit the script to run even higher resolutions.
Edit 4096 and 2160 at this line to the values you prefer:

WinMove, ahk_id %WindowID%, , 0, 0, 4096, 2160


m4v_stellar_class_red_dwarf_binary_brown_dwarfs__7_by_nirklars-d88d2li_png

Instant loading mode in SpaceEngine

There is a semi hidden option of changing the loading method inside space engine. It is insanely resource heavy and will freeze the game if you run out of memory.

Press the forward slash key / to toggle using Immediate, Interleaved or Asynchronous loading modes. (This is the apostrophe key on Swedish keyboards for some reason btw)

Immediate loading mode will attempt to load directly speeding up loading time. Avoid moving the camera or your position while in this mode! It will quickly queue up your actions in a buffer until your memory is full. (Which tends to freeze the game)

dfe4bbe7a26e67dfd7e0010ef4a55d12-d86axhn_pngThe sequence of taking high res screenshots

So after reading all this here is my own sequence for taking high res screenshots. Add anything else to this list that you like. If you find easier ways to do this please make sure to share them in the comment section!

 

1. Open up Graphics settings with CTRL+F4 and set your level of detail LOD to -2.0 before you go exploring.

2. When you find a good location, save it with F6.

3. Press ALT+ENTER to go to windowed mode and the Spacebar to pause time.

4. Configure other graphics settings or magnitudes and exposure menu using F7 to what you prefer.

5. Open up Graphics settings again with CTRL+F4 and set your level of detail LOD to 2.0

6. Press F12 to toggle 4096 x 2160 windowed mode. Expect a very low frame rate.

(At this time its useful to use hotkeys for opening options, since the toolbars are out of screen)

7. Press forward slash / to toggle to immediate loading mode. The game will most like freeze, this is normal so don’t click on anything.

8. Wait for it to finish loading and recover from the freeze. Cross your fingers it doesn’t crash… Grab a coffee or something 🙂

(A good way to tell when it has finished loading is to click an object with the selection pointer visible on screen. If the selection pointer is moving, it has finished loading.)

9.  Press F11 to capture a 4K screenshot!

10. Optional: Press SHIFT+C to toggle clouds and press F11 again.

11. Optional: Press SHIFT+A to disable atmospheres and take the last screenshot with F11.

12. Restart because you’re probably out of memory ! (Usually crashes or freezes here for me)

The optional images without atmosphere and clouds are useful if you want to do any post editing. For example placing them in different layers and changing transparency to your liking can be useful if you find beautiful landscapes but atmospheres are too thick and you need to adjust it afterwards.

Here are the results of adding together 3 images into a 4K high res render as described above. I have also added another copy of the layer without clouds or atmosphere; added a glow filter and manually erased parts if it to give it a somewhat glowing effect. Surreal yes, but pretty!

Alien shores lit by a never setting sun – 4096 x 2160 example
alien shores 4k

End words

If you keep getting crashes or permanent freezes while attempting to follow these instructions I’m sorry to say that your computer might not be up to the task. SpaceEngine can be quite resource demanding.

Here are my current computer specifications for comparison:
i7 870 2.93GHz OC ~3.2GHz
GeForce GTX 470 1280MB
16GB DDR3 1600Mhz
Samsung 840Pro 256GB SSD

If want to know more tricks about SpaceEngine you should go visit the forums!

Happy exploring!

More Space Engine

http://nirklars.deviantart.com/gallery/

ringed_dark_side_7k binary_pearls_7680x4320small_magellanic_cloud_by grains_of_silicate extrasolar_comet_4k exomoon_starfield__false_colour_4k

OpenGL error troubleshooting (updated 2016-01-11)

If you’ve been following this guide intently you may had crashes and encountered the following error message.
(Or perhaps another similar error message in case you have a ATI graphics card)

To see how you can workaround this click here for the separate post with instructions.

nvidia_opengl_lost_connection_error