jgraph / drawio-desktop

Official electron build of draw.io
https://www.diagrams.net
Apache License 2.0
50.04k stars 4.97k forks source link

Opening and saving a diagram exported as png discards export settings #1099

Open Griffon26 opened 2 years ago

Griffon26 commented 2 years ago

Preflight Checklist

You must agree to search and the code of conduct. You must fill in this entire template. If you delete part/all or miss parts out your issue will be closed.

Describe the bug Opening and saving a diagram exported as png may modify the diagram (it loses non-default export options such as border width and background).

To Reproduce Steps to reproduce the behavior:

  1. Create a new non-empty diagram (for example the default class diagram)
  2. Click on File -> Export as PNG...
  3. Set border width to 10
  4. Set "Include a copy of my diagram"
  5. Save it as a .png file
  6. Open the png file in an image viewer to confirm that it has a border
  7. Open the png file with draw.io-desktop again
  8. Click File -> Save
  9. Open the png file in an image viewer to confirm that it has no border

Expected behavior Opening a png exported with certain options and saving it should not result in a different image

Screenshots If applicable, add screenshots to help explain your problem. diagram_after_first_export diagram_after_consequent_save

draw.io version (In the Help->About menu of the draw.io editor):

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. See the FAQ for more information.

amamabel commented 1 year ago

Same here (v21.2.8). Save PNG with integrated diagram, open saved PNG with drawio, modify something and save it with ctrl-s leave the new PNG with many errors.

Workaround is to not save it via ctrl-s instead to use the export to PNG again.

kevinrobbins commented 1 year ago

I also ran into this issue, but I don't think this is a bug. I think the issue is that when exporting the diagram to PNG, the export settings are applied only to the image, but not the actual diagram. The diagram is embedded as-is and when you save the file again, the original diagram is saved. Unless you've configured the diagram settings to match what you select on PNG export, it will look wrong.

In my case, I exported without a transparent background and with a 10px border. After opening and saving again, the PNG had a transparent background and no border. To solve, I did the following:

  1. Set a background color for the diagram (e.g. white). By default the background is transparent. Apparently PNG export defaults to white. This option is found in the Diagram properties panel.
  2. Set the diagram border to 10px. This option was found under File -> Properties.

After making these changes, saving the PNG diagram resulted in the expected format.

github-actions[bot] commented 1 week ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. See the FAQ for more information.