Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screenshot distorts when compiling a latex document with it #3847

Open
5ila5 opened this issue Feb 18, 2025 · 2 comments
Open

Screenshot distorts when compiling a latex document with it #3847

5ila5 opened this issue Feb 18, 2025 · 2 comments
Labels
Bug It's a bug Good first issue Issues labeled as such are a good way to get use to the codebase. Ask for help if needed.

Comments

@5ila5
Copy link

5ila5 commented Feb 18, 2025

Flameshot Version

Flameshot v12.1.0 (7aa69e4)
Compiled with Qt 5.15.16

flameshot-git from AUR

Installation Type

User repository (AUR)

Operating System type and version

Up to date Arch linux

Description

Images taken with flameshot distorts when I include it in a latex document and compile it with pdflatex or lualatex. It also happens when including a image into a md file and converting it to a PDF using pandoc.

I guess it's some kind of metadata issue as it's fixed when converting the image with convert image.png -strip -density 300 converted.png

metadata of original image `identify -verbose image.png`

Image:
  Filename: image.png
  Permissions: rw-r--r--
  Format: PNG (Portable Network Graphics)
  Mime type: image/png
  Class: DirectClass
  Geometry: 743x345+0+0
  Resolution: 37.8x63.78
  Print size: 19.6561x5.40922
  Units: PixelsPerCentimeter
  Colorspace: sRGB
  Type: TrueColor
  Endianness: Undefined
  Depth: 8-bit
  Channels: 3.0
  Channel depth:
    Red: 8-bit
    Green: 8-bit
    Blue: 8-bit
  Channel statistics:
    Pixels: 256335
    Red:
      min: 0  (0)
      max: 255 (1)
      mean: 23.0503 (0.0903932)
      median: 10 (0.0392157)
      standard deviation: 42.9301 (0.168353)
      kurtosis: 13.1757
      skewness: 3.65033
      entropy: 0.197324
    Green:
      min: 0  (0)
      max: 255 (1)
      mean: 25.0201 (0.0981181)
      median: 14 (0.054902)
      standard deviation: 38.6762 (0.151671)
      kurtosis: 15.2523
      skewness: 3.86002
      entropy: 0.194134
    Blue:
      min: 0  (0)
      max: 255 (1)
      mean: 29.3873 (0.115244)
      median: 18 (0.0705882)
      standard deviation: 40.3997 (0.15843)
      kurtosis: 15.3
      skewness: 3.90189
      entropy: 0.197515
  Image statistics:
    Overall:
      min: 0  (0)
      max: 255 (1)
      mean: 25.8192 (0.101252)
      median: 14 (0.054902)
      standard deviation: 40.6686 (0.159485)
      kurtosis: 14.576
      skewness: 3.80408
      entropy: 0.196324
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33,0.03)
    green primary: (0.3,0.6,0.1)
    blue primary: (0.15,0.06,0.79)
    white point: (0.3127,0.329,0.3583)
  Matte color: grey74
  Background color: white
  Border color: srgb(223,223,223)
  Transparent color: black
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 743x345+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Zip
  Orientation: Undefined
  Properties:
    date:create: 2025-02-18T12:11:40+00:00
    date:modify: 2025-02-18T12:11:40+00:00
    date:timestamp: 2025-02-18T12:26:50+00:00
    png:IHDR.bit-depth-orig: 8
    png:IHDR.bit_depth: 8
    png:IHDR.color-type-orig: 2
    png:IHDR.color_type: 2 (Truecolor)
    png:IHDR.interlace_method: 0 (Not interlaced)
    png:IHDR.width,height: 743, 345
    png:pHYs: x_res=3780, y_res=6378, units=1
    signature: a3e6009196e99ea777bf3317f511c192997a9cc22760dcd73bbe1e2d0bb6c5b2
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 34775B
  Number pixels: 256335
  Pixel cache type: Memory
  Pixels per second: 64.9518MP
  User time: 0.000u
  Elapsed time: 0:01.003
  Version: ImageMagick 7.1.1-43 Q16-HDRI x86_64 22550 https://imagemagick.org
metadata of converted image `identify -verbose converted.png`
Image:
  Filename: converted.png
  Permissions: rw-r--r--
  Format: PNG (Portable Network Graphics)
  Mime type: image/png
  Class: DirectClass
  Geometry: 743x345+0+0
  Units: Undefined
  Colorspace: sRGB
  Type: TrueColor
  Endianness: Undefined
  Depth: 8-bit
  Channels: 3.0
  Channel depth:
    Red: 8-bit
    Green: 8-bit
    Blue: 8-bit
  Channel statistics:
    Pixels: 256335
    Red:
      min: 0  (0)
      max: 255 (1)
      mean: 23.0503 (0.0903932)
      median: 10 (0.0392157)
      standard deviation: 42.9301 (0.168353)
      kurtosis: 13.1757
      skewness: 3.65033
      entropy: 0.197324
    Green:
      min: 0  (0)
      max: 255 (1)
      mean: 25.0201 (0.0981181)
      median: 14 (0.054902)
      standard deviation: 38.6762 (0.151671)
      kurtosis: 15.2523
      skewness: 3.86002
      entropy: 0.194134
    Blue:
      min: 0  (0)
      max: 255 (1)
      mean: 29.3873 (0.115244)
      median: 18 (0.0705882)
      standard deviation: 40.3997 (0.15843)
      kurtosis: 15.3
      skewness: 3.90189
      entropy: 0.197515
  Image statistics:
    Overall:
      min: 0  (0)
      max: 255 (1)
      mean: 25.8192 (0.101252)
      median: 14 (0.054902)
      standard deviation: 40.6686 (0.159485)
      kurtosis: 14.576
      skewness: 3.80408
      entropy: 0.196324
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33,0.03)
    green primary: (0.3,0.6,0.1)
    blue primary: (0.15,0.06,0.79)
    white point: (0.3127,0.329,0.3583)
  Matte color: grey74
  Background color: white
  Border color: srgb(223,223,223)
  Transparent color: black
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 743x345+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Zip
  Orientation: Undefined
  Properties:
    date:create: 2025-02-18T12:16:52+00:00
    date:modify: 2025-02-18T12:16:52+00:00
    date:timestamp: 2025-02-18T12:28:31+00:00
    png:IHDR.bit-depth-orig: 8
    png:IHDR.bit_depth: 8
    png:IHDR.color-type-orig: 2
    png:IHDR.color_type: 2 (Truecolor)
    png:IHDR.interlace_method: 0 (Not interlaced)
    png:IHDR.width,height: 743, 345
    signature: a3e6009196e99ea777bf3317f511c192997a9cc22760dcd73bbe1e2d0bb6c5b2
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 34581B
  Number pixels: 256335
  Pixel cache type: Memory
  Pixels per second: 63.0047MP
  User time: 0.000u
  Elapsed time: 0:01.004
  Version: ImageMagick 7.1.1-43 Q16-HDRI x86_64 22550 https://imagemagick.org

Steps to reproduce

Download: as image.png
Image

run convert image.png -strip -density 300 converted.png on that image or download: as converted.png
Image

create a main.tex file with the content:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
    \includegraphics[width=0.9\linewidth]{image.png}
    \caption{original}
\end{figure}

\begin{figure}
    \includegraphics[width=0.9\linewidth]{converted.png}
    \caption{Converted}
\end{figure}
    

\end{document}

run lualatex main.tex the resulting PDF has one distorted and one correct image

Alternative using pandoc:

Create a md file containing:

![alt text](converted.png)
![alt text](image.png)

and run pandoc test.p.md -o test.p.pdf

Screenshots or screen recordings

Latex Output
Image

Pandoc Output
Image

System Information

operating System

Arch linux 6.13.2-arch1-1

Monitor Config

Image

DP-0 connected 1080x1920+5760+120 left (normal left inverted right x axis y axis) 527mm x 296mm
DP-2 connected 1920x1080+0+540 (normal left inverted right x axis y axis) 527mm x 296mm
DP-4 connected primary 3840x2160+1920+0 (normal left inverted right x axis y axis) 710mm x 400mm

Windows manager

Xorg, Qtile

@5ila5 5ila5 added the Unconfirmed Bug The bug is not confirmed by anyone else. label Feb 18, 2025
@FelixJochems
Copy link

This is an intricate issue. Qt offers little control over the metadata when saving. My guess is that since the QPixmap is exact pixel data, it encodes the Physical pixel dimensions (PHY) into the image.

Your converted image just completely deleted all the physical size info and set the Units to "undefined". So I'm not even sure if this is a bug on our end. The only issue we could maybe tackle is the DevicePixel/Aspect ratio being wrong when saving the image.

Could you try to compile a LaTeX document with a screenshot made while only having the dell P2417H in landscape mode connected? This eliminates a lot of factors and could help determine if this is an issue we can fix or if it's a Qt issue (or something in the LaTeX compile pipeline)

Massive thanks for the incredible amount of detail on the bug, makes it so much easier to pinpoint!

@5ila5
Copy link
Author

5ila5 commented Feb 19, 2025

I did some more testing, and it looks like this only happens when I have at least one horizontal and the one vertical monitor. It looks fine when taking the screenshot on the vertical monitor if only the vertical one is connected, and it looks fine when the vertical monitor is not connected. (somehow it still distorts if the monitor is connected, and I then disable it in NVIDIA-settings panel, but I don't think that's relevant here)

So it looks like the metadata is being calculated wrongly when there is a mix between vertical and horizontal monitors (maybe with multiple verticals as well, did not test that)

@FelixJochems FelixJochems added Bug It's a bug Good first issue Issues labeled as such are a good way to get use to the codebase. Ask for help if needed. and removed Unconfirmed Bug The bug is not confirmed by anyone else. labels Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug It's a bug Good first issue Issues labeled as such are a good way to get use to the codebase. Ask for help if needed.
Projects
None yet
Development

No branches or pull requests

2 participants