DPI metadata of PNG export should change with scale or be adjustable
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 18.8k
- Forks
- 2.8k
- Merge moyen
- 16 h 26 min
- PR mergées (30 j)
- 21
Description
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.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par le chemin d’exportation Python write_image et comparez les métadonnées PNG produites avec scale=1 et scale=2. Vérifiez les dimensions physiques obtenues dans un autre logiciel d’image ; c’est terminé lorsque la mise à l’échelle des pixels ne modifie plus la taille physique, ou lorsqu’une option dpi permet de contrôler les métadonnées comme demandé.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- data-visualization
- Type d'issue
- Fonctionnalité
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 45/100