Introduction
This script provides a simple way of extracting all the images from a RESX file (used by C# and VB) to store resources used in forms.
Background
I created this script because I was looking for a quick way of extracting all the images from a VB project I was converting to C++. I found utilities that allow for extracting single images, but nothing quick and easy that would do it all in one go.
A bit of research told me that the files were using base64
encoding so it was fairly easy to create a script using perl features like:
use MIME::Base64
to import the functions I needed to do the conversion. After that, I just needed to scan for the right resources and output each one to a folder using the name of the resource as a base filename.
Using the Code
The script is very easy to use. All you need to do is provide it an input file and an optional output file in the following manner:
perl --to outputfolder inputfile
The script itself is very simple and relies on simple text pattern matching to find the resources and in its current form only extracts Bitmap (BMP) and Icon (ICO) files, but should be easily extended by modifying this section:
if ($type =~ /^System.Drawing.Bitmap, System.Drawing/)
{
$filename = "$outputfolder/$name.bmp";
}
elsif ($type =~ /^System.Drawing.Icon, System.Drawing/)
{
$filename = "$outputfolder/$name.ico";
}
to match the resource of interest.
History
- 6th July, 2017: Initial version