123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. *
  3. * @authors Eric Hsiao
  4. *
  5. */
  6. main = function () {
  7. //private menbers
  8. var templateData;
  9. var templateData2;
  10. var photoData;
  11. //private methods
  12. function init() {
  13. console.log('main is loaded.');
  14. var userphotoHelper = new photoHelper();
  15. $('.plotoUpLoad__btn').change(function (e) {
  16. e.preventDefault();
  17. userphotoHelper.loadFile('.plotoUpLoad__btn',function (_photoData) {
  18. console.log('Photo has loaded.');
  19. photoData = _photoData;
  20. $('.output').attr('src', photoData);
  21. });
  22. });
  23. var templeteHelper = new photoHelper();
  24. $('.templeteUpLoad__btn').change(function (e) {
  25. e.preventDefault();
  26. templeteHelper.loadFile('.templeteUpLoad__btn',function (_photoData) {
  27. console.log('templete has loaded.');
  28. templateData = _photoData;
  29. $('.templete_output').attr('src', templateData);
  30. });
  31. });
  32. $('.faceFusion__start').click(function (e) {
  33. e.preventDefault();
  34. var _faceFusionAlpha = $('.faceFusion__alpha').val();
  35. // var _templateURL = 'https://ncxpre.cecmartech.com/main/%5BEric%5DphotoHelper/images/demo2.jpg';
  36. //傳入 樣板URL:_templateURL 自動轉Base64
  37. //傳入 使用者圖片:photoData(base64)
  38. //傳入 融合參數:_faceFusionAlpha 預設0.49
  39. //返回 _merge_image(base64)
  40. faceFusionAPI.start(templateData, photoData, _faceFusionAlpha, function (_merge_image) {
  41. //_merge_image
  42. $('.faceFusion').attr('src', _merge_image);
  43. });
  44. });
  45. }
  46. //constructor
  47. {
  48. $(document).ready(function () {
  49. init();
  50. });
  51. }
  52. //public
  53. return {
  54. }
  55. }
  56. main = new main();