zurich has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to create a perl script which encodes images to base64. This shall be used to transfer images via xml to another system.
I created the following script to read the capture.png file:
use MIME::Base64; open (my $image, 'Z:\capture.png') or die "$!"; $raw_string = do{ local $/ = undef; <$image>; }; $encoded = encode_base64( $raw_string );
For the beginning, I just re-write into a new file photo.png
my $decoded= MIME::Base64::decode_base64($encoded); open my $fho, '>', 'Z:\photo.png' or die $!; binmode $fho; print $fho $decoded;
The photo.png is created with exactly the same size as the input photo, however the newly created file can't be opened.
I also comared the base64 value with the value created by an online encoding webpage (using the same input photo) and this is different.
I would be very happy if somebody could help me out with this!
Thanks a lot in advance. Best regards zurich
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: image encode base64 - help needed
by Corion (Patriarch) on Feb 11, 2016 at 14:32 UTC | |
|
Re: image encode base64 - help needed
by graff (Chancellor) on Feb 12, 2016 at 00:38 UTC |