Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
BLP.NET CL is a command-line tool where you can encode and decodeBLP (Blizzard images) into various image codecs.
This is a superset of Shadow Daemon's BLP Laboratory CL. If you attempt to encode a BLP image with BLP.NET CL, it will unpack the "blplabcl.exe" and "swdn_blp.dll" files in its current directory and use it for BLP encoding.
This tool is inspired of ffmpeg, and again blplabcl.
If you are creative enough, you can do big things with this tool.
Features
- Can encode and decode BLP images to various image codecs: BMP, GIF, JPG, PNG, WEBP, TGA and DDS.
- Can only decode the following image codecs: ICO, WBMP, DNG
- Can add or remove alpha channels when converting back into BLP.
- Since this is a superset of BLP Laboratory CL, you can set the BLP Type (Compressed or Paletted), set mipmaps, set the quality, and have the option flags (Merge headers, Compress palette, Progressive encoding, and Error diffusion).
- Assorted commands in the command-line tool that provide useful information.
- Paint.NET BLP file type plugin that relies on BLP.NET CL.
Limitations
- The current BLP decoder cannot support BLP0.
- During my tests, the TGA decoder can fail when loading a TGA image coming from BLP Laboratory (GUI).
Image codec
Decoder
Encoder
BLP
War3Net.Drawing.Blp 5.6.1
BLP Laboratory CL
TGA
Gorgon.Graphics.Imaging 3.2.30.304
Gorgon.Graphics.Imaging 3.2.30.304
DDS
Gorgon.Graphics.Imaging 3.2.30.304
Gorgon.Graphics.Imaging 3.2.30.304
BMP
SkiaSharp 2.88.8
Gorgon.Graphics.Imaging 3.2.30.304
GIF
SkiaSharp 2.88.8
Gorgon.Graphics.Imaging 3.2.30.304
JPG
SkiaSharp 2.88.8
SkiaSharp 2.88.8
PNG
SkiaSharp 2.88.8
SkiaSharp 2.88.8
WEBP
SkiaSharp 2.88.8
SkiaSharp 2.88.8
ICO
SkiaSharp 2.88.8
Not supported
WBMP
SkiaSharp 2.88.8
Not supported
DNG
SkiaSharp 2.88.8
Not supported
Just run Install_BlpDotNet.bat with Run on Administrator, and you will have this in your Paint.NET too. (Choo choo girl not included)
Future Plans
- Github repository so others can contribute.
- A command where you can use pipes to input and output image binaries instead of File IO.
- Output options for other image codecs.
Motivation
I am working on a map where I'm automating the version labelling of the whole map. This includes the war3mapPreview.tga and the loading screen where it indicates the map version. It reached to the point I am using 3 different command-line tools to deal with the image conversions and I noticed most of them had issues with encoding and decoding images. Most solutions I found in Hive uses graphical user interface (GUI) and have zero command-line features. I had enough and introduce a solution to my problem: BLP.NET CL. Also, I'm a Paint.NET user and it is frustrating BLP file type plugins does not work in the modern versions. Good thing making this hit two birds with one stone.
Now get ready to type blpnetcl, or let your automation tools do the blpnetcl for you.
Choo choo!
0.1.1
- blpnetcl.exe will now unpack 'libSkiaSharp.dll' file to fix the dependency issue for other computers
0.1.0
- First version
BLP.NET CL
Copyright (c) 2024 Glint
License is MIT
BLP.NET is made with C#. The target framework of this project is .NET 8.0.
Image encoders and decoders used War3Net.Drawing.Blp, BLP Laboratory CL, SkiaSharp, and Gorgon.
It pains with my heart, this is a Windows only command-line tool unless it works on WINE.
If people are interested in this tool, I will try to upload the project in Github.
Approved! A useful command line tool for file format conversion with a lot of configurability. It is a bit slow though for BLP conversion but so is BLP Lab and this is using that internally.
It is a version of BLP that is used in Reign of Chaos (ROC) Beta.
I'm not very familiar with it but it is heavily discussed in this post. In summary, the difference between BLP0 and BLP1 is how mipmaps are handled.
I never encountered a use-case dealing with BLP0 in my projects. If it becomes a demand in the future, I can try to find a way to decode (and hopefully encode) it in BLP.NET CL.
Can this tool batch optimize a folder containing .blp files to .blp with lets say, 75% quality?
On an unrelated note on the tool, do you know of a way to separate mdx/blp files from other bloat/unused mdx/blp files? I have a list of mdx files my map uses, I just need to delete all other mdx files that isn't in this list, but then I have to check associated textures too, but this is very time consuming since theres over hundreds of models, got any ideas?
BLP.NET CL doesn't necessarily have batch operations but you can achieve it by executing the tool multiple times within a script file.
Assuming your operating system is Windows, create a .bat file inside the target folder and write the following batch script in your favorite text editor:
Code:
@echo off
rem Replace "%appdata%\BLP.NET\bin" where your blpnetcl is located
set blpnetclpath=%appdata%\BLP.NET\bin
set path=%path%;%blpnetclpath%
for %%f in (*.blp) do (
if "%%~xf"==".blp" blpnetcl %%f %%~nf.blp -q 75
)
Once you save the .bat file, try running it. It should turn all the blp files inside the folder with 75% quality.
On an unrelated note on the tool, do you know of a way to separate mdx/blp files from other bloat/unused mdx/blp files? I have a list of mdx files my map uses, I just need to delete all other mdx files that isn't in this list, but then I have to check associated textures too, but this is very time consuming since theres over hundreds of models, got any ideas?
BLP.NET CL doesn't necessarily have batch operations but you can achieve it by executing the tool multiple times within a script file.
Assuming your operating system is Windows, create a .bat file inside the target folder and write the following batch script in your favorite text editor:
Code:
@echo off
rem Replace "%appdata%\BLP.NET\bin" where your blpnetcl is located
set blpnetclpath=%appdata%\BLP.NET\bin
set path=%path%;%blpnetclpath%
for %%f in (*.blp) do (
if "%%~xf"==".blp" blpnetcl %%f %%~nf.blp -q 75
)
Once you save the .bat file, try running it. It should turn all the blp files inside the folder with 75% quality.
That is a very specific case. The one I found in Hive is this tool but I noticed you had issues with it.
You could try this simple program I made that does the same thing. If you still have problem with this, you can freely PM me.
Omg, absolutely amazing. The bat file works and the simple program as well. Blp to 75% quality works, almost no quality loss (can't see any to be fair). Map size reduced quite well, overall this was an amazing discovery, thanks for your amazing contribution Glint.
edit: Btw, I don't think this bat file can parse files with spaces in them?it seem to treat "myTexture hello.blp" as "myTexture"
edit2: Had ChatGPT revise it a bit, for anyone curious, this is what I'm using at the moment
Bash:
@echo off
setlocal enabledelayedexpansion
rem Get the total number of .blp files
set count=0
for %%f in (blp\*.blp) do (
set /a count+=1
)
rem Process each file and display progress
set processed=0
echo ====================================================
echo Processing BLP Files
echo ====================================================
for %%f in (blp\*.blp) do (
set /a processed+=1
echo [File %%~nf.blp] Processing file !processed! of %count% ...
if "%%~xf"==".blp" blpnetcl "%%f" "%%~nf.blp" -q 50
)
echo ====================================================
echo Process Complete
echo ====================================================
endlocal
pause
I think there might be something wrong with the program? I used 65% quality, and a lot of textures are bugged, like they look somewhat like this (on multiple characters)
I think there might be something wrong with the program? I used 65% quality, and a lot of textures are bugged, like they look somewhat like this (on multiple characters) View attachment 480279View attachment 480280
PS. I noticed for the texture, I had a duplicate but with .tga extension instead, I deleted it now, but do you think that could be the cause? Although I had several models affected by this, so I don't know.
Eg.
myTexture.blp
I also had:
myTexture.tga
(forgot to remove these tga files)
PS. I noticed for the texture, I had a duplicate but with .tga extension instead, I deleted it now, but do you think that could be the cause? Although I had several models affected by this, so I don't know.
Eg.
myTexture.blp
I also had:
myTexture.tga
(forgot to remove these tga files)
I remember a friend of mine have this issue when we have both BLP and TGA textures with the same filename in our map. The solution I did was to remove the TGA copy.
Also, I found out another reason why the model is not shown properly: BLP.NET CL (as of 0.1.1) default mipmap value is set to 0. You could quickly fix this by adding the -m 15 option.
Example: blpnetcl a.blp a.blp -q 75 -m 15
You could lower the mipmap value as low as 1 to get a 30.33% file size reduction. Lowering the mipmap count may crash players who are running your map on a Mac. (Reference)
Your batch file should look like this with the fix:
Bash:
@echo off
setlocal enabledelayedexpansion
rem Get the total number of .blp files
set count=0
for %%f in (blp\*.blp) do (
set /a count+=1
)
rem Process each file and display progress
set processed=0
echo ====================================================
echo Processing BLP Files
echo ====================================================
for %%f in (blp\*.blp) do (
set /a processed+=1
echo [File %%~nf.blp] Processing file !processed! of %count% ...
if "%%~xf"==".blp" blpnetcl "%%f" "%%~nf.blp" -q 50 -m 15
)
echo ====================================================
echo Process Complete
echo ====================================================
endlocal
pause
Thanks for your help on this one. Once I push an update, the default mipmap value should now be 15.
I remember a friend of mine have this issue when we have both BLP and TGA textures with the same filename in our map. The solution I did was to remove the TGA copy.
Also, I found out another reason why the model is not shown properly: BLP.NET CL (as of 0.1.1) default mipmap value is set to 0. You could quickly fix this by adding the -m 15 option.
Example: blpnetcl a.blp a.blp -q 75 -m 15
You could lower the mipmap value as low as 1 to get a 30.33% file size reduction. Lowering the mipmap count may crash players who are running your map on a Mac. (Reference)
Your batch file should look like this with the fix:
Bash:
@echo off
setlocal enabledelayedexpansion
rem Get the total number of .blp files
set count=0
for %%f in (blp\*.blp) do (
set /a count+=1
)
rem Process each file and display progress
set processed=0
echo ====================================================
echo Processing BLP Files
echo ====================================================
for %%f in (blp\*.blp) do (
set /a processed+=1
echo [File %%~nf.blp] Processing file !processed! of %count% ...
if "%%~xf"==".blp" blpnetcl "%%f" "%%~nf.blp" -q 50 -m 15
)
echo ====================================================
echo Process Complete
echo ====================================================
endlocal
pause
Thanks for your help on this one. Once I push an update, the default mipmap value should now be 15.
Approved! A useful command line tool for file format conversion with a lot of configurability. It is a bit slow though for BLP conversion but so is BLP Lab and this is using that internally.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.