DPI metadata of PNG export should change with scale or be adjustable
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 18.8k
- 派生
- 2.8k
- 平均合并
- 16 小时 26 分钟
- 30 天内合并 PR
- 21
描述
I export a figure as a png using write_image:
fig.update_layout(width=300).write_image("test_1.png", scale=1)
Opening this image in another program, the width of the image is 3.125 inches corresponding to a DPI of 96.
If I instead export an image with a different scale, e.g. 2
fig.write_image("test_2.png", scale=2)
I get a png file with a scaled pixel width (e.g. 600).
But opening the image in another program, the width in inches is also doubled to 6.25.
The ideal behavior IMO would be that the width of the image in inches is unaffected by the scale parameter or having a dpi keyword argument that sets the DPI metadata directly.
A workaround (which others might find useful) is to use Pillow to fix the DPI metadata
from PIL import Image
scale = 2
Image.open("test_2.png").save("test_2_fixed.png", dpi=(96 * scale, 96 * scale))
such that the image defaults to the same size in inches in other programs independent of the scale.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Python 的 write_image 导出路径开始,比较使用 scale=1 和 scale=2 生成的 PNG 元数据。在另一个图像程序中验证所得的物理尺寸;当缩放像素不再改变物理尺寸,或 dpi 选项能够提供所需的元数据控制时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- data-visualization
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100