common javascript image routines