support interaction between js and app; save preview as jpg