// Define this once and before it will be called, hence at the top of this file function DrawRefimg(fig, img, canvas, orig_face ) { // FIXME: should get this from shared.py, not sure why this doesnt work at present thumbsize=256 context=canvas.getContext('2d') // another call to this func will occur on load, so skip this one if( img.width == 0 ) return // only set canvas.width once we have valid img dimensions canvas.width=img.width/2 // actually draw the pixel images to the canvas at the right size context.drawImage(img, 0, 0, img.width/(img.height/canvas.height), canvas.height); fig.width(canvas.width) // draw rectangle on face context.beginPath(); new_x=(orig_face.x/orig_face.orig_w)*img.width/(img.height/canvas.height) new_y=(orig_face.y/orig_face.orig_h)*thumbsize/(img.height/canvas.height) new_w=(orig_face.w/orig_face.orig_w)*img.width/(img.height/canvas.height) new_h=(orig_face.h/orig_face.orig_h)*thumbsize/(img.height/canvas.height) context.rect(new_x, new_y, new_w, new_h) context.lineWidth = 2; context.strokeStyle = 'green'; context.stroke(); }