plotly / plotly/plotly.py

DPI metadata of PNG export should change with scale or be adjustable

オープン
#4,015 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

feature P3
主要言語
Python
スター
18.8k
フォーク
2.8k
平均マージ
16時間 26分
マージ済み PR(30日)
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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Python の write_image エクスポートパスから始め、scale=1 と scale=2 で生成される PNG メタデータを比較します。別の画像プログラムで結果の物理的な寸法を確認します。ピクセルのスケーリングによって物理的なサイズが変わらなくなるか、dpi オプションによって要求されたメタデータの制御が可能になれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
data-visualization
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。