Created
December 11, 2012 14:15
-
-
Save branch14/4258871 to your computer and use it in GitHub Desktop.
convert json signatures captured by thomasjbradley's signature-pad to an image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# see https://github.com/thomasjbradley/signature-pad for more details | |
instructions = JSON.load(data).map { |h| "line #{h['mx']},#{h['my']} #{h['lx']},#{h['ly']}" } * ' ' | |
system "convert -size 198x55 xc:transparent -stroke blue -draw '#{instructions}' signature.png" |
@lrbz - checkout signature-pad's options'. By default stroke is 2px wide, but you can adjust it :)
create file field hidden id profile_signature for attachment
var canvas = document.querySelector("canvas");
var imfile;
canvas.toBlob((blob) => {
imfile = new File([blob], "signature.jpg", { type: "image/jpeg" })
let dt = new DataTransfer();
dt.items.add(imfile);
document.getElementById("profile_signature").files = dt.files;
});
first it will convert base64 into image and then attach it to your hidden field
create file field hidden id profile_signature for attachment
var canvas = document.querySelector("canvas"); var imfile; canvas.toBlob((blob) => { imfile = new File([blob], "signature.jpg", { type: "image/jpeg" }) let dt = new DataTransfer(); dt.items.add(imfile); document.getElementById("profile_signature").files = dt.files; });
first it will convert base64 into image and then attach it to your hidden field
Here, the field "profile_signature" will look like what in HTML?
@harshitDispatch Looks like it should be a <input type="file">
@harshitDispatch Looks like it should be a
<input type="file">
@branch14 Yeah that worked. Thanks for the help.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is there any way to adjust the stroke font size ?