willowsystems/jSignature — pull request #17 by shrimpwagon (2013-01-15 21:00:54+00:00)
Title: Added png image and signature line options

Added options for outputting .png - not applicable to svg, base30, etc. I figured these are needed additions since a large signature div is helpful but outputting the .png at the same size is not. I added options to set the width and/or height, scale width/or height, proportion lock and edge trim. It can trim off the excess white space!!! Also, added new init option to leave off the signature since this appears in the .png. I just substituted the line with some HTML/CSS. I'm sure yall can figure that one out.

Observe the new options:

Scale picture by 1/2 and trim off white space:

$('#signature').jSignature('getData', 'image', {
'scaleX': .5,
'trim': true
});

Set the width to 200px and do not proportionally resize height:

$('#signature').jSignature('getData', 'image', {
'width': '200px',
'lock': false
});

Mixing the 'width' and 'height' options with 'scaleX' and 'scaleY' options will be confusing and I don't recommend it. Basically, the width and height gets established first before scaling. So specifying 'width' will result in the image being resized at that width but if you also indicate 'scaleX' then it will be scaled AFTER being resized. Just don't do it!!!

Options	Default	Description
-----------------------------------------------------------
width	'canvas.width'	Sets the png width
(takes precedence before scaleX)
height	'canvas.height'	Sets the png height
(takes precedence before scaleY)
scaleX	1	Sets the png width by multiplying
current width. If 'width' is also
set, that value gets scaled.
scaleY	1	Sets the png height by multiplying
current height. If 'height' is also
set, that value gets scaled.
trim	false	Trims off any clear edge pixel, ie
if RGBA is 0,0,0,0, ie no color.
lock	true	Set the correct proportion for other
dimension if not given. By setting
a value for 'width', 'height' will
set set proportionally. This also
works for 'scaleX' and 'scaleY'

Here is how to remove the signature line:

$('#signature').jSignature({
'signatureLine': false
});