[pm-h] saving an image generated by an HTML5 canvas

Fraser Baker flbaker at sbcglobal.net
Sat Jan 3 09:28:38 PST 2015


Hi Y'all:

 

I am stumped. I want to save the contents of an HTML5 canvas to a png image
file. The following code is from the Internet, but the file that is saved is
not a valid image file. So far, this is what I have: 

 

I pass the image as a 64 bit text image to the server using the following
form element:

 

document.form.signature_url.value = signaturePad.toDataURL();



On the server, I: 

 

use MIME::Base64 qw( decode_base64url ); I get the same results if I use
decode_base64

 

@encoded_signature = split/,/, $signature_url;

$decoded_signature = decode_base64url($encoded_signature[1]);



Then I save the image:

 

$filename = 'sig_'.$client_id.'_'.$mySqlDate.'_'.$sigTime.'.png';
$rootPathSigsFilename = $rootPathSigs.'/'.$filename;



open(SIG, ">$rootPathSigsFilename");
print SIG $decoded_signature;
close(SIG);



The image is indeed saved and it is about 30k in size but the saved image is
invalid.

 

>From what I can glean the issue may have something to do with URI versus
UURL formatting, but what do I know.

 

Any suggestions will be greatly appreciated.

 

Fraser

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/houston/attachments/20150103/309ce018/attachment.html>


More information about the Houston mailing list