Skip to content

Support saving PCX images with dpi - #10710

Merged
radarhere merged 3 commits into
python-pillow:mainfrom
guru-bharadwaj20:pcx-save-dpi
Dec 3, 2026
Merged

radarhere merged 3 commits into
python-pillow:mainfrom
guru-bharadwaj20:pcx-save-dpi

Conversation

@guru-bharadwaj20

Copy link
Copy Markdown
Contributor

The PCX header has 16-bit horizontal and vertical resolution fields, and PcxImagePlugin reads them into info["dpi"]. When saving, though, the resolution is hardcoded to 100, so im.save("out.pcx", dpi=(300, 300)) reopens with (100, 100).

Changes proposed in this pull request:

  • Use the dpi save argument when it is given, rounded to integers. Without it, 100 dpi is still written, so existing output doesn't change.
  • Add test_dpi to Tests/test_file_pcx.py, covering the default, an explicit value and float rounding.
  • Document the new save argument under PCX and add a release note.

Checks run locally (Linux, Python 3.14):

  • python3 -m pytest Tests/test_file_pcx.py Tests/test_file_dcx.py: 43 passed.
  • With the plugin change reverted, test_dpi fails with (100, 100) == (300, 150).
  • pre-commit run on the changed files and mypy on the plugin and test file pass.

The PCX header has horizontal and vertical resolution fields, and the reader exposes them as info["dpi"], but saving always wrote 100 dpi. Use the dpi argument when given, rounded to integers like other formats.
Copilot AI balanced review requested due to automatic review settings December 3, 2026 05:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Comment thread docs/releasenotes/13.1.0.rst Resolved
@radarhere radarhere added the 🤖-assisted AI-assisted label Dec 3, 2026
@radarhere
radarhere enabled auto-merge (squash) December 3, 2026 06:10
@radarhere
radarhere merged commit 16b1c33 into python-pillow:main Dec 3, 2026
55 of 56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖-assisted AI-assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants