KineticJS icon indicating copy to clipboard operation
KineticJS copied to clipboard

[4.6.0] toDataURL does not return correct image when putImageData is used

Open rylanhalteman opened this issue 13 years ago • 3 comments

Description

I am using KineticJS in conjunction with JSManipulate, and recently upgraded KineticJS from 4.0.5 to 4.6.0. Since I upgraded, I can no longer use stage.toDataURL() properly, it returns the wrong image.

My application allows users to do the following:

  • select a background image
  • apply a transformation to the image (using JSManipulate)
  • save the image (with extra text)

The JSManipulate workflow is involves getting the canvas image, applying the transformation, and returning the new image using getImageData() and putImageData(). Instead of returning the image on the canvas, stage.toDataURL() returns what is on the canvas, substituting the transformed image with the original background image.

Ex.

Screenshot of canvas Canvas screen Screenshot of image returned by canvas.context.toDataURL() Canvas screen Screenshot of image returned by stage.backgroundLayer.toDataURL() Canvas screen Screenshot of image returned by stage.toDataURL() Canvas screen

Summary & Workaround

I believe this is an issue either with the image's or layer's toDataURL() method, or the way KineticJS handles the putImageData(). This is a regression bug introduced since 4.0.5, and has been around for at least 3 months, given #453.

I have implemented a workaround which involves creating a new image background using the canvas' dataURL when I save the canvas.

rylanhalteman avatar Aug 13 '13 20:08 rylanhalteman

I should mention that I'm using a custom download with Core, Image, Rect, Text, Animation, and DragAndDrop.

rylanhalteman avatar Aug 13 '13 20:08 rylanhalteman

Truly sorry for the headache. This issue will be fixed by v4.6.1 or v4.6.2, depending on priorities. Thanks for hanging in there!

ericdrowell avatar Aug 13 '13 21:08 ericdrowell

Looking forward to the fix; thanks for all your hard work!

rylanhalteman avatar Aug 14 '13 13:08 rylanhalteman