bergben / ng2-img-max

Angular 2 module to resize images down to a certain width and height or to reduce the quality to fit a certain maximal filesize - all in the browser.
MIT License
83 stars 46 forks source link

"exif-js": "^2.3.0" causes Uncaught (in promise): ReferenceError: EXIF is not defined ReferenceError: EXIF is not defined #38

Closed SnezanaDichevska closed 6 years ago

SnezanaDichevska commented 6 years ago

Latest exif-js (specified as dependency)causes errors when using ng2-img-max resizing method. Reprosteps - resize bigger images 4-5MB

ReferenceError: EXIF is not defined
    at eval (webpack:///./~/ng2-pica/dist/src/img-exif.service.js?:13)
    at new ZoneAwarePromise (webpack:///./~/zone.js/dist/zone.js?:834)
    at ImgExifService.getOrientedImage (webpack:///./~/ng2-pica/dist/src/img-exif.service.js?:11)
    at Image.img.onload (webpack:///./~/ng2-pica/dist/src/ng2-pica.service.js?:66)
    at Image.wrapFn [as __zone_symbol___onload] (webpack:///./~/zone.js/dist/zone.js?:1056)
    at ZoneDelegate.invokeTask (webpack:///./~/zone.js/dist/zone.js?:424)
    at Object.onInvokeTask (webpack:///./~/@angular/core/@angular/core.es5.js?:4128)
    at ZoneDelegate.invokeTask (webpack:///./~/zone.js/dist/zone.js?:423)
    at Zone.runTask (webpack:///./~/zone.js/dist/zone.js?:191)
    at Image.ZoneTask.invoke (webpack:///./~/zone.js/dist/zone.js?:486)
    at Image.c (newrelic.min.js:1)
    at eval (webpack:///./~/ng2-pica/dist/src/img-exif.service.js?:13)
    at new ZoneAwarePromise (webpack:///./~/zone.js/dist/zone.js?:834)
    at ImgExifService.getOrientedImage (webpack:///./~/ng2-pica/dist/src/img-exif.service.js?:11)
    at Image.img.onload (webpack:///./~/ng2-pica/dist/src/ng2-pica.service.js?:66)
    at Image.wrapFn [as __zone_symbol___onload] (webpack:///./~/zone.js/dist/zone.js?:1056)
    at ZoneDelegate.invokeTask (webpack:///./~/zone.js/dist/zone.js?:424)
    at Object.onInvokeTask (webpack:///./~/@angular/core/@angular/core.es5.js?:4128)
    at ZoneDelegate.invokeTask (webpack:///./~/zone.js/dist/zone.js?:423)
    at Zone.runTask (webpack:///./~/zone.js/dist/zone.js?:191)
    at Image.ZoneTask.invoke (webpack:///./~/zone.js/dist/zone.js?:486)
    at Image.c (newrelic.min.js:1)
    at resolvePromise (webpack:///./~/zone.js/dist/zone.js?:770)
    at resolvePromise (webpack:///./~/zone.js/dist/zone.js?:741)
    at eval (webpack:///./~/zone.js/dist/zone.js?:818)
    at ZoneDelegate.invokeTask (webpack:///./~/zone.js/dist/zone.js?:424)
    at Object.onInvokeTask (webpack:///./~/@angular/core/@angular/core.es5.js?:4128)
    at ZoneDelegate.invokeTask (webpack:///./~/zone.js/dist/zone.js?:423)
    at Zone.runTask (webpack:///./~/zone.js/dist/zone.js?:191)
    at drainMicroTaskQueue (webpack:///./~/zone.js/dist/zone.js?:584)
    at Image.ZoneTask.invoke (webpack:///./~/zone.js/dist/zone.js?:490)
    at Image.c (newrelic.min.js:1)
    at ____________________Elapsed_6_ms__At__Thu_Aug_16_2018_14_18_39_GMT_0200__Central_European_Summer_Time_ ()
    at Object.onScheduleTask (webpack:///./~/zone.js/dist/long-stack-trace-zone.js?:109)
    at ZoneDelegate.scheduleTask (webpack:///./~/zone.js/dist/zone.js?:404)
    at Object.onScheduleTask (webpack:///./~/zone.js/dist/zone.js?:300)
    at ZoneDelegate.scheduleTask (webpack:///./~/zone.js/dist/zone.js?:404)
    at Zone.scheduleTask (webpack:///./~/zone.js/dist/zone.js?:235)
    at Zone.scheduleMicroTask (webpack:///./~/zone.js/dist/zone.js?:255)
    at scheduleResolveOrReject (webpack:///./~/zone.js/dist/zone.js?:816)
    at ZoneAwarePromise.then (webpack:///./~/zone.js/dist/zone.js?:905)
    at Image.img.onload (webpack:///./~/ng2-pica/dist/src/ng2-pica.service.js?:66)
    at Image.wrapFn [as __zone_symbol___onload] (webpack:///./~/zone.js/dist/zone.js?:1056)
    at ZoneDelegate.invokeTask (webpack:///./~/zone.js/dist/zone.js?:424)
    at Object.onInvokeTask (webpack:///./~/@angular/core/@angular/core.es5.js?:4128)
    at ZoneDelegate.invokeTask (webpack:///./~/zone.js/dist/zone.js?:423)
    at Zone.runTask (webpack:///./~/zone.js/dist/zone.js?:191)
    at Image.ZoneTask.invoke (webpack:///./~/zone.js/dist/zone.js?:486)
    at Image.c (newrelic.min.js:1)
    at ____________________Elapsed_182_ms__At__Thu_Aug_16_2018_14_18_39_GMT_0200__Central_European_Summer_Time_ ()
    at Object.onScheduleTask (webpack:///./~/zone.js/dist/long-stack-trace-zone.js?:109)
    at ZoneDelegate.scheduleTask (webpack:///./~/zone.js/dist/zone.js?:404)
    at Object.onScheduleTask (webpack:///./~/zone.js/dist/zone.js?:300)
    at ZoneDelegate.scheduleTask (webpack:///./~/zone.js/dist/zone.js?:404)
    at Zone.scheduleTask (webpack:///./~/zone.js/dist/zone.js?:235)
    at Zone.scheduleEventTask (webpack:///./~/zone.js/dist/zone.js?:261)
    at zoneAwareAddListener (webpack:///./~/zone.js/dist/zone.js?:1279)
    at Image.proto.(anonymous function) [as addEventListener] (webpack:///./~/zone.js/dist/zone.js?:1426:20)
    at Image.desc.set [as onload] (webpack:///./~/zone.js/dist/zone.js?:1063)
    at eval (webpack:///./~/ng2-pica/dist/src/ng2-pica.service.js?:65)
    at new ZoneAwarePromise (webpack:///./~/zone.js/dist/zone.js?:834)
    at Ng2PicaService.resizeFile (webpack:///./~/ng2-pica/dist/src/ng2-pica.service.js?:61)
    at Ng2PicaService.resize (webpack:///./~/ng2-pica/dist/src/ng2-pica.service.js?:20)
    at eval (webpack:///./~/ng2-img-max/dist/src/img-maxpx-size.service.js?:65)
    at ZoneDelegate.invoke (webpack:///./~/zone.js/dist/zone.js?:391)
    at Object.onInvoke (webpack:///./~/@angular/core/@angular/core.es5.js?:4137)
    at ZoneDelegate.invoke (webpack:///./~/zone.js/dist/zone.js?:390)
    at Zone.run (webpack:///./~/zone.js/dist/zone.js?:141)
    at eval (webpack:///./~/zone.js/dist/zone.js?:818)
    at ZoneDelegate.invokeTask (webpack:///./~/zone.js/dist/zone.js?:424)
    at Object.onInvokeTask (webpack:///./~/@angular/core/@angular/core.es5.js?:4128)
    at ZoneDelegate.invokeTask (webpack:///./~/zone.js/dist/zone.js?:423)
    at Zone.runTask (webpack:///./~/zone.js/dist/zone.js?:191)
    at drainMicroTaskQueue (webpack:///./~/zone.js/dist/zone.js?:584)
    at ____________________Elapsed_4_ms__At__Thu_Aug_16_2018_14_18_39_GMT_0200__Central_European_Summer_Time_ ()
    at Object.onScheduleTask (webpack:///./~/zone.js/dist/long-stack-trace-zone.js?:109)
    at ZoneDelegate.scheduleTask (webpack:///./~/zone.js/dist/zone.js?:404)
    at Object.onScheduleTask (webpack:///./~/zone.js/dist/zone.js?:300)
    at ZoneDelegate.scheduleTask (webpack:///./~/zone.js/dist/zone.js?:404)
    at Zone.scheduleTask (webpack:///./~/zone.js/dist/zone.js?:235)
    at Zone.scheduleMicroTask (webpack:///./~/zone.js/dist/zone.js?:255)
    at scheduleResolveOrReject (webpack:///./~/zone.js/dist/zone.js?:816)
    at resolvePromise (webpack:///./~/zone.js/dist/zone.js?:765)
    at eval (webpack:///./~/zone.js/dist/zone.js?:696)
    at Image.eval (webpack:///./~/ng2-img-max/dist/src/img-exif.service.js?:64)
    at handleBinaryFile (webpack:///./~/ng2-img-max/dist/src/exif.js?:95)
    at FileReader.fileReader_1.onload (webpack:///./~/ng2-img-max/dist/src/exif.js?:107)
    at ZoneDelegate.invoke (webpack:///./~/zone.js/dist/zone.js?:391)
    at Object.onInvoke (webpack:///./~/@angular/core/@angular/core.es5.js?:4137)
    at ZoneDelegate.invoke (webpack:///./~/zone.js/dist/zone.js?:390)
    at Zone.runGuarded (webpack:///./~/zone.js/dist/zone.js?:154)
    at FileReader.eval (webpack:///./~/zone.js/dist/zone.js?:132)
jacksonhart commented 6 years ago

Occurs on any size image I believe.

replacing import 'exif-js/exif'; in img-exif.service.js with var EXIF = require('exif-js'); fixed this for me.

I'm not sure what to do with the .ts file in src however - not sure how to build/compile into js to test and the ts doesn't recognise 'require'. Can anyone have a go at this?

@bergben i know you're trying to not support this anymore but we're so close :p (and it seems the recent changes to support Angular 6 have broken it for everyone)

bergben commented 6 years ago

Hey @jacksonhart! Thanks for figuring out what the problem is - I was guessing it has to be something like this! I can fix it in the ts files and build and publish it, will do it soon (today)!

SnezanaDichevska commented 6 years ago

The problem occurs in ng-pica ReferenceError: EXIF is not defined at eval (webpack:///./~/ng2-pica/dist/src/img-exif.service.js?:13

bergben commented 6 years ago

I just released version 2.1.18, can you guys test if it's working with the fix @jacksonhart suggested and report back? Thanks!

fmq commented 6 years ago

@bergben I had the same issue, upgraded to 2.1.18 and the issue is resolved, thanks!