HappenApps / Quiver

Quiver documentation and issue tracker
2.26k stars 109 forks source link

Pasting an image from the clipboard give always an JPEG file #1254

Open quark67 opened 5 years ago

quark67 commented 5 years ago

This result in a loss of quality, especially when the image comes from a screenshot. Moreover, this seems to be a regression, as I find previous Quiver notes with screenshots images in PNGs.

Steps to reproduce the bug:

  1. Take a screenshot on the Mac, in the clipboard, with the usual shortcuts (for example, with cmd+ctrl+4)
  2. Paste the content of the clipboard in a Markdown cell (with cmd+V)

Result:

![IMAGE](quiver-image-url/XXXxxxXXXXXxxxxXXXX.jpg )

A PNG file can be more relevant in this context. In fact, after step 1, if you go to Finder > Edit > Show Clipboard, you'll read: Clipboard contents: Portable Network Graphics image.

So, why after pasting to a markdown cell, this give a JPEG file?

Same after pasting to a text cell, but it is less immediately visible that we obtain a JPEG file.

If we work in Preview.app, we can see a cross cursor in the image, and select a portion of an image. If we copy this portion of image (cmd+C), we read in Finder > Edit > Show Clipboard: Clipboard contents: TIFF image. But in fact, the clipboard also contain the image in the PNG format. Proof: In Applescript Editor, run:

set c to clipboard info

In the log, you will see something like:

{​​​​​{​​​​​​​TIFF picture, ​​​​​​​167546​​​​​}, ​​​​​{​​​​​​​«class 8BPS», ​​​​​​​21084​​​​​}, ​​​​​{​​​​​​​GIF picture, ​​​​​​​1787​​​​​}, ​​​​​{​​​​​​​«class jp2 », ​​​​​​​11487​​​​​}, ​​​​​{​​​​​​​JPEG picture, ​​​​​​​4824​​​​​}, ​​​​​{​​​​​​​«class PNGf», ​​​​​​​5751​​​​​}, ​​​​​{​​​​​​​«class BMP », ​​​​​​​164218​​​​​}, ​​​​​{​​​​​​​«class TPIC», ​​​​​​​6684​​​​​}​​​}

You can force the clipboard to contain only a PNG file:

set the clipboard to (the clipboard as «class PNGf»)

After that, we read in Finder > Edit > Show Clipboard: Clipboard contents: Portable Network Graphics image.

So, even if the clipboard contain TIFF file, it probably contain also a PNG version of the image.

I strongly suggest you to favourite PNG file if available in the clipboard, and only in last ressort use the JPEG format. Thanks.

ijoseph commented 5 years ago

This is related in a roundabout way to Text Cell PDF Images Disappear , in that PDF images are also not handled correctly.

I agree that PNGs used to be handled better (or at least differently), though, as evidenced by how terrible the PNGs now look when I paste them in. This is what led me to realize the above issue, actually.