Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Extracting Images from a RESX File

0.00/5 (No votes)
6 Jul 2017 1  
A simple way of extracting all images from a RESX file using a simple perl script

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

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here