Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exportWithBackgroundImage does not work when background image is set using datauri #105

Open
DevonPeroutky opened this issue Dec 29, 2022 · 6 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers
Milestone

Comments

@DevonPeroutky
Copy link

Describe the bug
First of all, this project is awesome. However, what is preventing me from using it, is that there is a bug when adding a backgroundImage from a dataURI, and then attempting to export the image without the background image

To Reproduce
To reproduce

  1. Go to the demo
  2. Add a background image from a dataURI (Can be anything)
  3. Add some strokes
  4. Uncheck exportWithBackgroundImage
  5. Export Image

Expected behavior
Image is exported without the background image.

Actual behavior
Image is exported with the background image. Note: The SVG is exported correctly, without the background image.

Screenshots
Screen Shot 2022-12-29 at 4 35 06 PM

Desktop (please complete the following information):

  • OS: Mac OS
  • Browser: Chrome
@vinothpandian
Copy link
Owner

Hi @DevonPeroutky,

Thanks for reporting it. I'll update the title to reflect the issue correctly. I saw a few PRs I'll fix this too while merging them in the next version.

@vinothpandian vinothpandian changed the title exportWithBackgroundImage behavior is broken exportWithBackgroundImage does not work when background image is set using datauri Jan 3, 2023
@vinothpandian vinothpandian added bug Something isn't working good first issue Good for newcomers labels Jan 3, 2023
@vinothpandian vinothpandian self-assigned this Jan 16, 2023
@eltoob
Copy link

eltoob commented Mar 13, 2023

Hey
It seems like the issue is still there?
Is there a workaround?

@neer2005
Copy link

My workaround by removing the background image before exporting the image:

  const onExport = () => {
    setState({ ...state, backgroundImageDataUrl: "0" });
  };

  useEffect(() => {
    if (state.backgroundImageDataUrl === "0") {
      canvas.current
        ?.exportImage("png")
        .then((dataUrl) => console.log(dataUrl))
        .catch((err) => console.error(err));
    }
  }, [canvas, state.backgroundImageDataUrl]);

button:

<button onClick={onExport}>export</button>

@maxmoeschinger
Copy link

I experience the same problem when using the following prop:

preserveBackgroundImageAspectRatio={
    'xMidYMid meet'
}

@maxcmoi89
Copy link

I have the same issue. Any idea when we can expect a fix ?

For the rest, the library works really well.

@pzich
Copy link

pzich commented Oct 3, 2023

Hey! Just started using this library last night and ran into the same thing. Any chance it can get fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

7 participants