plotly / plotly/plotly.py

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

Abierto
#4,015 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

feature P3
Lenguaje dominante
Python
Estrellas
18.8k
Forks
2.8k
Merge medio
16 h 26 min
PR fusionados (30 d)
21

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza por la ruta de exportación de Python write_image y compara los metadatos PNG producidos con scale=1 y scale=2. Verifica las dimensiones físicas resultantes en otro programa de imágenes; se considera terminado cuando escalar los píxeles ya no cambia el tamaño físico, o cuando una opción dpi proporciona el control de metadatos solicitado.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
data-visualization
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.