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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With