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

[bluesky] gallery-dl neglects downloading higher quality PNG version of images #6603

Closed
klazoklazo opened this issue Dec 4, 2024 · 5 comments

Comments

@klazoklazo
Copy link

Noticed something with Bluesky's image URLs. There's a modifier at the end that lets you choose between whether you want to see a JPEG/JPG version or a PNG version:

image

Modifying the URL to end in @png instead of @jpeg results in the downloaded image being of higher quality. Here's a post and two downloaded images as an example:

The post: https://bsky.app/profile/fruttymoment.bsky.social/post/3lcdqq3x47s2h

Then downloading after clicking on the image to view it in full as opposed to the preview:

@jpeg

Then modifying the URL's ending parameter to show a PNG instead of a JPEG:

@png

If you zoom in on both images you can notice that the PNG indeed doesn't include the compression artifacts that the JPEG has (although they're relatively faint here since the image is so simple). I tested it with an image I presumed to be already compressed and Bluesky seems to recompress JPEGs since the PNG version also contains some compression artifacts but not as much as the JPEG version. Although technically I can't be exactly sure if the image I used as an example was uploaded originally as a JPEG as a PNG or just as a JPEG, I'd assume it'd be the latter since the former would take considerably more effort. (Example image here, feel free to test it out and see for yourself: https://bsky.app/profile/oofmasterxd.bsky.social/post/3lchnegnrfj2b)

I'd like to request that gallery-dl is modified to have an option to download in either JPEG or PNG quality, and additionally that this option is set to PNG by default (although I'm still fine with downloads remaining in JPEG by default, just that the option is there to download in PNGs).

@klazoklazo klazoklazo changed the title [bluesky] gallery-dl fails to download higher quality PNG version of images when available [bluesky] gallery-dl neglects downloading higher quality PNG version of images Dec 4, 2024
@mikf
Copy link
Owner

mikf commented Dec 4, 2024

gallery-dl currently downloads the sync.getBlob version of images and videos, which is somewhat different from the JPEG or PNG version that can be downloaded on bluesky with a web browser.

https://bsky.app/profile/mikf.bsky.social/post/3kkzc3xaf5m2w

https://conocybe.us-west.host.bsky.network/xrpc/com.atproto.sync.getBlob?did=did:plc:cslxjqkeexku6elp5xowxkq7&cid=bafkreib7ydpe3xxo4cq7nn32w7eqhcanfaanz6caepd2z4kzplxtx2ctgi
https://cdn.bsky.app/img/feed_fullsize/plain/did:plc:cslxjqkeexku6elp5xowxkq7/bafkreib7ydpe3xxo4cq7nn32w7eqhcanfaanz6caepd2z4kzplxtx2ctgi@jpeg
https://cdn.bsky.app/img/feed_fullsize/plain/did:plc:cslxjqkeexku6elp5xowxkq7/bafkreib7ydpe3xxo4cq7nn32w7eqhcanfaanz6caepd2z4kzplxtx2ctgi@png

You can find more (and by now probably outdated) information in #4438 and #4438 (comment)

@klazoklazo
Copy link
Author

Yeah after some checking I think your remark on the information being probably outdated is true?

The note on fullsize upscaling images to 2000x? or ?x2000 no longer applies as of I think October, found in this solved issue thread on the Bluesky GitHub: bluesky-social/social-app#1101

As a result I think it would now be worth it to instead focus on downloading fullsize images in PNG format as opposed to the originals, especially since you justify the choice on original with upscaling low resolution images further distorting image quality: #4438 (comment)

@goodusername123
Copy link

goodusername123 commented Dec 5, 2024

Requesting a PNG from the standard URLs/server that is called when you open the embed from within a post is actually technically lower quality (as in generation loss) then the JPEGs that gallery-dl downloads. This is because from what I have observed when an image is uploaded to Bluesky it internally gets converted to a quality 100 YUV JPEG and when you request a "PNG" from the servers it simply converts the quality 100 YUV JPEG to a PNG and then serves that which uh isn't good considering that quality 100 YUV JPEGs are not actually lossless as the transformation from RGB to YUV cannot be losslessly reversed and is done slightly different between different JPEG decoders due to mathematical precision or otherwise not being the same which results in the decoded to RGB pixels being very slightly different, So the JPEG versions of images that gallery-dl downloads are actually one step closer to what was originally uploaded.
RGB_YCbCr

tl;dr: The JPEGs that gallery-dl currently downloads from Bluesky are better and have one less step of generation loss then what you are doing to request PNGs from their servers.

@klazoklazo
Copy link
Author

OH true, I tried obtaining the blob URL for the example post I had originally provided and I could tell no difference between the PNG and blob versions. Perfectly fine with this being the default then.

@Hrxn
Copy link
Contributor

Hrxn commented Dec 5, 2024

Yeah, what @goodusername123 said. Whatever you upload, probably it gets through their default JPEG processing stage and is stored recompressed on their systems. And whatever they serve, PNG, what not, is then simply derived from that.

It's not like the old golden days of tumblr where you could actually get the original uploaded files, as is. That would be too good to be true nowadays.

@mikf mikf closed this as not planned Won't fix, can't repro, duplicate, stale Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants