dotfiles icon indicating copy to clipboard operation
dotfiles copied to clipboard

[BUG] Screenshot generates mismatch between contents of the file vs. it's extension

Open eljejer opened this issue 5 months ago • 11 comments

Describe the bug

I have taken a screenshot which I would like to upload to imglink.cc This upload results in an error message : "File content does not match its extension"

Steps to reproduce

  1. SUPER PrtScr
  2. Immediate
  3. Capture Active Display
  4. Copy & Save
  5. upload file to imglink.cc

Expected behavior

I would expect that uploading to imglink.cc would not pose a problem

Screenshots

Screenshot in question: this file

Screenshot of error message: this

Distribution

Other (please specify below)

If Other, specify

CachyOS

Additional context

To be able to upload the screenshot in question nevertheless, I convert the file:

magick screenshot.jpg screenshot.png

and use the png version to upload to imglink.cc

Also, when I did this, I was on rolling 2.13.1

I was made aware of an update around the screenshot facility. So I tried it again after updating to 2.14.0 Same result

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

eljejer avatar Jun 28 '26 07:06 eljejer

@eljejer - What's the output of pacman -Q | grep grim from your terminal? Also, what's the output of less ~/.config/ml4w/settings/screenshot-filename?

hurlbutt avatar Jun 28 '26 15:06 hurlbutt

@eljejer - What's the output of pacman -Q | grep grim from your terminal? Also, what's the output of less ~/.config/ml4w/settings/screenshot-filename?

pacman -Q | grep grim
grim 1.5.0-2.1
grimblast-git r154.541628c-1

$
less ~/.config/ml4w/settings/screenshot-filename

screenshot_$(date +%Y%m%d_%H%M%S).jpg
/home/eljejer/.config/ml4w/settings/screenshot-filename (END)

eljejer avatar Jun 28 '26 15:06 eljejer

Thanks for sharing @eljejer . While it's not the latest version of grimblast, it's recent enough that it should support --filename. In your steps to reproduce, you mention that you used the Copy & Save option. grimblast's TYPE option only supports PNG when copy actions are invoked (from man grimblast):

     -t TYPE, --filetype TYPE
         Output filetype. Supported: png, ppm, jpeg. Default: png. Note: copy and copysave actions only support PNG format.

If you were to choose the "Save" option with the screenshot-filename setting ending in .jpg, does that file correctly save as JPEG? That can be checked on the command line with identify /path/to/file | awk '{print $2}'.

hurlbutt avatar Jun 28 '26 17:06 hurlbutt

@hurlbutt Yes, the screenshot does correctly save as JPEG when I choose "Save" in stead of "Copy & Save"

eljejer avatar Jun 28 '26 18:06 eljejer

@eljejer - Sounds good. I ran into this limitation when coding #1650 due to the reliance on grimblast. I thought of other features to add (e.g. more file types like WEBP, BMP; setting quality preferences), but felt that it should be its own feature plan as we'd need to refactor settings, decide on acceptable quality lost due to file format shifting, and create a new interface to interact with these settings.

Given the current dependencies on grimblast, I would say that this Copy/Save behavior is expected behavior, but we should open a new Feature issue describing what an ideal screen capture settings experience should be to foster discussion and direction.

hurlbutt avatar Jun 28 '26 19:06 hurlbutt

@hurlbutt Agreed on the "own feature plan" regarding support of alternative file types.

With respect to the original "bug" report, I actually don't remember why I have grown the habit of choosing "Copy & Save" when screen-shooting. In my personal use case, I can gladly choose "Save" from now on.

Other users might fall in this " trap" however; when their screenshot is becoming the subject in some process where it's file type does not match it's contents and this poses a problem.

This being said, I don't know what to do with the status of this "bug";

  • close and wait for possible user reports
  • refrain from the flexibility of being able to define a file type for screenshots in .config/ml4w/settings/screenshot and make it fixed "omg"
  • ???

eljejer avatar Jun 28 '26 19:06 eljejer

I've created #1684 to capture ideas from the community with regards to screen capture features (e.g. allow for copy as PNG and save as a preferred format). As far as I can tell, this is the first time I've seen a bug filed for the format discrepancy (I had observed it myself, but I decided to fix it in code and push a PR rather than filing a bug). I'm not sure if others realize that they've been saving PNGs as opposed to JPGs (and even the default value for the filename implies a PNG).

@eljejer - The only "good" solution I can think of is to issue a system notification in the event a "Copy & Save" action occurs for a JPEG or PPM image to let them know that it's being overwritten as PNG. If we want that as an enhancement, I can look into it.

hurlbutt avatar Jun 28 '26 22:06 hurlbutt

@hurlbutt a 3rd option might be to change the type to be fixed PNG. After all, that's what is generated at the moment, is it not?

eljejer avatar Jun 29 '26 06:06 eljejer

The screenshot feature is completely broken after the last update, for any mode, entire screen, selection, immediate and delayed.

Seeing this error in every case: "Unknown subject to take a screenshot from".

Juraci avatar Jun 29 '26 14:06 Juraci

@Juraci - A PR was raised on Saturday (#1680) to ensure all users had the latest version of grimblast, but it did not make the build cut. I have a comment in the PR to @mylinuxforwork that we'll likely need a point release to address this issue.

hurlbutt avatar Jun 29 '26 15:06 hurlbutt

I will look into it soon. Thanks for your support here.

mylinuxforwork avatar Jun 29 '26 19:06 mylinuxforwork