DPI metadata of PNG export should change with scale or be adjustable
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 18.8k
- Fork
- 2.8k
- Merge trung bình
- 16 giờ 26 phút
- Pull request đã merge (30 ngày)
- 21
Mô tả
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.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu từ đường dẫn xuất Python write_image và so sánh siêu dữ liệu PNG được tạo ra với scale=1 và scale=2. Xác minh các kích thước vật lý thu được trong một chương trình hình ảnh khác; được xem là hoàn tất khi việc thay đổi tỷ lệ pixel không còn làm thay đổi kích thước vật lý, hoặc khi một tùy chọn dpi cung cấp khả năng kiểm soát siêu dữ liệu được yêu cầu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- data-visualization
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100