Jump to content

Kerbal Image Converter


Recommended Posts

hello

i figured i would make it in its own thread instead of flooding the other one with any more bug reports.

for those not familiar with the program it will batch convert all the 24 bit PNG files in the parts folder to 32 bit format thus removing the red texture bug from your parts.

this is a link to the newest version of the program.

https://github.com/downloads/hollow87/Kerbal-Image-Converter/KerbalImageConveter.zip

as before you have to do is place the EXE in your KSP folder and run it.

the code has now been optimized some more.

as for the error well... to be honest we have no idea on what the cause is and i have tried every thing to reproduce it and could not.

how ever we have added some code that will tell us what part it is on when the error occurs in an attempt to track down the problem.

so when the error occurs please post it so we can have a look at it.

Link to comment
Share on other sites

  • 2 weeks later...

About the error - check DERP pack. When I tried the converter, it found DERP habitation module (its texture already is 32 bit) and returned out of memory error. Seems that error is caused by some strange files, that really aren\'t correct images.

Because there are 2 png files in the folder

NewHabitation_tex.png - 32 bit texture

._NewHabitation_tex.png - maybe something like some graphics redactor temporary file. Can\'t be recognized by graphic redactors/viewers and causes the converter\'s error.

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...
  • 1 month later...

I tried putting it in the folder (where it says parts, ships, KSP, etc.) but that didn\'t work, then i opened the KSP application in 7zip and copying it in (with the image converter also in 7zip) but that didn\'t work either.

In the folder it seems to run, but it gets an error and stops working and doesn\'t convert anything.

So... er.... Help?

Link to comment
Share on other sites

I\'m on OS X and couldn\'t find a fast way to convert all my PNGs to 32 bit.

So I wrote this quick PHP script. It should actually work in windows too, but who knows (not tested)?

Hope it works for you guys :)

Instructions


  • [li]Save this code to a file called convert.php. I suggest putting it in your home folder: /Users/yourusername/[/li]
    [li]Open a terminal window and navigate to the folder containing convert.php[/li]
    [li]Run convert.php with the path to your KSP/Parts/ folder as the argument[/li]
    [li]Done![/li]

Example

3TWCT.png

Code

#!/usr/bin/php
<?php

// Folder is first argument
$Folder = $argv[1];
if (!file_exists($Folder) || !is_dir($Folder))
exit(1);

$ConvertFiles = array();
FindPNGs($Folder, $ConvertFiles);

foreach ($ConvertFiles as $ConvertFile)
ConvertPNG($ConvertFile);

function FindPNGs($Folder, &$ConvertFiles) {
$Files = scandir($Folder);
foreach ($Files as $File) {
if (in_array($File, array(\'.\',\'..\'))) continue;
$RealFile = CombinePaths(array($Folder, $File));

if (is_dir($RealFile)) {
FindPNGs($RealFile, $ConvertFiles);
continue;
}

if (substr($File, -3) == \'png\') {
$ConvertFiles[] = $RealFile;
}
}
}

function ConvertPNG($PNGFile) {
echo ' > converting {$PNGFile}\n';
$PngImage = imagecreatefrompng($PNGFile);
imagealphablending($PngImage, FALSE);
imagesavealpha($PngImage, TRUE);
imagepng($PngImage, $PNGFile);
}

function CombinePaths($Paths, $Delimiter = \'/\') {
if (is_array($Paths)) {
$MungedPath = implode($Delimiter, $Paths);
$MungedPath = str_replace(array($Delimiter.$Delimiter.$Delimiter, $Delimiter.$Delimiter), array($Delimiter, $Delimiter), $MungedPath);
return str_replace(array(\'http:/\', \'https:/\'), array(\'[url]http://\'[/url], \'[url]https://\'[/url]), $MungedPath);
} else {
return $Paths;
}
}

?>

Link to comment
Share on other sites

SOLUTION:

Calling all Kerbalnauts who are having difficulty in running Anti-Sanity\'s excellent 'Kerbal Image Converter'.

I believe the 'Kerbal Image Converter' requires that you have 'MS.NET Framework 4' already installed on your PC for it to successfully run.

Here\'s the background as I understand it...

The red tint on mesh skins is the effect of the older 24bit PNG file format (Win XP) which when saving, would automatically remove the Alpha channel (transparent background) if it was empty. KSP expects 32bit PNG files which do include an Alpha channel. So, when KSP encounters a 24bit PNG with no Alpha channel, it ends up displaying a default semi-transparent red over all the channels.

(i.e. 8bit for Red + 8bit for Green + 8bit for Blue channels = 24bit + 8bit for Alpha = 32bit)

Use the \'Kerbal Image Converter\' to batch convert *ALL* the 24bit PNG files in the \'Parts\' folder to 32bit format in one simple step!

• Make sure you have already installed 'MS.NET Framework 4' or else , the 'Kerbal Image Converter' will not run successfully.

• If you don\'t have 'MS.NET Framework 4' already installed, download and install it now.

Here\'s a link to Microsoft site where you can download it:

http://www.microsoft.com/download/en/details.aspx?id=17718

• Place the 'KerbalImageConverter.exe' file in your KSP folder.

(Where your 'KSP.exe' file is located.)

*NOT* in the \'Parts\' folder.

• Now run the 'KerbalImageConverter.exe' file and it will automatically scan all the files in your \'Parts\' folder and

convert those pesky 24bit files (no alpha) to the desired 32bit format (with alpha).

Now you can sit back and relax, knowing all your \'parts\' are no longer... red... ahem!

Job done ;D

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

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...