Accessing a Microsoft Clipart Download from Linux

Written by James McDonald

October 3, 2009

If you go to Microsoft has a heap of images…

If you read the service agreement you will probably find that you would be better off using services that publish their content via a creative commons license or another open license.

However I digress.

If you are on Linux and you do download an MPF package from the MS clipart site. How do you unpack them?

I tried the Perl utility at but when trying to open the mpf file I got the following error

./ ClipArt-jm.mpf 
Not an ARRAY reference at ./ line 75.

This was caused because the clipart.mpf download only had one image in it…. If you download the clipart.mpf file with more than one image this doesn’t occur:

./ ClipArt.mpf 
Extracted ./j0442361.jpg
Extracted ./j0442360.jpg
Extracted ./j0442355.jpg

I did code a work-around for the problem. Which involved testing for and changing what was passed into the foreach statement in the mpftools perl script:

my $data = XMLin($mpffile);
# from the line above change it to be as follows
my @ref;

# added this to print the mpf xml to screen
#print Dumper($data->{'D:response'});

# this code checks to see if the return from the $data-> call 
# is a hash ( a single xml node ) or an array (multiple D:response nodes)
if ( $data->{'D:response'} =~ /array/i ) {
	@ref = @{$data->{'D:response'}};
	print "It's an Array\n"; 
} else {
	print "it's a hash\n";
	@ref = $data->{'D:response'};

# so when we go into the foreach the @ref is always an array
# unlike before when it was a hash when it was only 
# a single photo in the mpf
# loop on the files
foreach my $response (@ref) {

If any Perl monk can tell me how to test for an array/hash better than this please comment below.

1 Comment

  1. Luca

    Had your same problem with a mpf file with only an image in it, applied your code: everything is working great! Many many thanks!!


Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…

Clear HSTS Settings in CHrome

Open chrome://net-internals/#hsts enter the domain in the query field and click Query to confirm it has HSTS settings...

Ubuntu on Hyper-v

It boils town to installing linux-azure # as root or sudo apt-get update apt-get install linux-azure...