Closed ghost closed 10 years ago
OK. I just solved the issue
caman = null
_.each files, (file) ->
...
img = new Image()
img.onload = ->
if caman?
caman.loadImage @, ->
@resize height: 300
@render ->
upload @canvas.toDataUrl
else
caman = Caman @, ->
@resize height: 300
@render ->
upload @canvas.toDataUrl
...
Just found & tried this loadImage
method, and it works!
Still would love to hear your insights if there is a better solution.
Thanks.
Hi,
I came across your package recently and really enjoyed it until today when I started integrating CamanJS with my project at work and stumbled into this issue.
TL;DR
Uncaught TypeError: undefined is not a function
new Image()
with dataUrl, without a visible canvas or image tag in the browser, like this:Scenario
I'm using CamanJS in browser, where I
I initialize Caman with a
new Image()
object in a_.each files
after user chooses the images:Problem
The problem happens when I need to upload multiple images. All the images are the same as the first one uploaded. If I upload them separately, they are still the same, that is, unless I reload the page every single time.
Current Status
Now I know that before
Caman @, ->
, the image is correct every time, but in the callback of Caman initializer (afterCaman @, ->
), the image stays unchanged every time.I tried
reset()
,reloadCanvasData()
,revert(true/false)
, and etc. But they all throw the errorUncaught TypeError: undefined is not a function
.revert()
actually change the picture to an unrecognizable image.Thanks
Sorry for the long form. I added a tl;dr section at the beginning. I'd love to get some insights from you, and solve this issue as soon as I can.