Skip to content

fix: PNG backend generates ASCII text instead of binary PNG data #227

@krystophny

Description

@krystophny

Issue Description

The PNG backend is generating files with ASCII text content instead of proper binary PNG image data. This causes all PNG images in documentation to be broken and non-functional.

Problem Details

  • PNG files are being created but contain ASCII text instead of binary PNG image data
  • Example: curl shows PNG files are "ASCII text" instead of "PNG image data"
  • The file command shows "ASCII text" instead of "PNG image data"
  • HTML img tags are correct but images don't load because they're text files
  • PDF files work correctly (binary content), but PNG files are broken

Evidence

# PNG files return HTTP 200 but contain text content
curl -I https://lazy-fortran.github.io/fortplot/plots/basic_plot.png
# Shows Content-Type: text/plain instead of image/png

file plots/basic_plot.png
# Shows "ASCII text" instead of "PNG image data"

Impact

  • All documentation images are broken, making visual examples non-functional
  • Users cannot see plot examples in the documentation
  • Severely impacts user experience and documentation quality

Root Cause

The PNG backend is likely writing text output instead of proper binary PNG data, possibly due to:

  • Incorrect file mode (text vs binary)
  • Wrong output format in PNG generation code
  • Backend configuration issues

Acceptance Criteria

  • PNG files contain proper binary PNG image data
  • file command shows "PNG image data" for generated PNG files
  • PNG images display correctly in web browsers
  • Documentation images load and display properly
  • HTTP Content-Type headers are correct for PNG files

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions