Reputation: 3454
I have a variable $photo
(huge string that has been base64 encoded) that I believe I need to decode it using MIME::Base64
with something like this:
my $decoded= MIME::Base64::decode_base64($photo);
now after that how to I make $decoded back into a jpg as it was before?
Upvotes: 4
Views: 5620
Reputation: 54373
You can write it to a file just like you can write any other data. You need to set the filehandle to binary, though.
my $decoded= MIME::Base64::decode_base64($photo);
open my $fh, '>', 'photo.jpg' or die $!;
binmode $fh;
print $fh $decoded;
close $fh
Upvotes: 11