DPI metadata of PNG export should change with scale or be adjustable
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 18.8k
- Fork
- 2.8k
- Merge medio
- 16h 26m
- PR unite (30g)
- 21
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Parti dal percorso di esportazione Python write_image e confronta i metadati PNG prodotti con scale=1 e scale=2. Verifica le dimensioni fisiche risultanti in un altro programma per immagini; il lavoro è completato quando il ridimensionamento dei pixel non modifica più le dimensioni fisiche, oppure quando un’opzione dpi fornisce il controllo richiesto sui metadati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- data-visualization
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100