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

Pixiv's ugoira zip files are actually samples #6056

Closed
hdk5 opened this issue Aug 19, 2024 · 2 comments
Closed

Pixiv's ugoira zip files are actually samples #6056

hdk5 opened this issue Aug 19, 2024 · 2 comments

Comments

@hdk5
Copy link

hdk5 commented Aug 19, 2024

The original (or at least less badly compressed) frames can be obtained from https://i.pximg.net/img-original/img/20xx/xx/xx/xx/xx/xx/{id}_ugoira{n}.{ext} urls, where n=[0; number-of-frames). The number of frames should be grabbed from ugoira metadata api.

For example:
https://www.pixiv.net/artworks/101003492
101003492_ugoira1920x1080.zip: JPEG q=90, downscaled to 1080x1080, no transparency, visible artifacts inside/around "pixels"
101003492_ugoira0.png: PNG lossless, 1210x1210, transparent background, no artifacts
image
image

This applies not only to images with dimensions above 1920x1080 and/or jpg ; another example:
https://www.pixiv.net/artworks/116464967
116464967_ugoira1920x1080.zip: JPEG q=90, same artifacts
116464967_ugoira0.jpg: JPEG q=99, feels lossless, no artifacts on pixel art
image
image

I used low-palette pixel art works as examples since it is easier to show the difference. In reality, most artists usually just convert their animated works to gif and then pixiv frame-by-frame converts it to jpg, so there's still unavoidable re-encoding involved.

See danbooru/danbooru#5793 at danbooru for any additional details.

@mikf
Copy link
Owner

mikf commented Sep 1, 2024

Downloading "original" frames is now possible by setting ugoira to "original" / -o ugoira=original (9d1e5f3).

Converting them to animated formats should work as well, but there might be a few bugs for edge cases and --ugoira currently overrides -o ugoira=original (57da9eb).


Is there a better way to get an "original" frame's filename extension other than just guessing?

for ext in ("jpg", "png", "gif"):
try:
url = ("{}0.{}".format(base, ext))
self.request(url, method="HEAD")
break
except exception.HttpError:
pass

@hdk5
Copy link
Author

hdk5 commented Sep 1, 2024

Is there a better way to get an "original" frame's filename extension other than just guessing?

It is always the same as the first frame's, as pixiv won't let one upload frames of different filetypes.

Can't say about the api that gallery-dl uses, but on ajax/illust it is in body.urls.original field, e.g.:

$ curl -s https://www.pixiv.net/ajax/illust/101003492 | jq ".body.urls.original"
"https://i.pximg.net/img-original/img/2022/09/04/23/54/19/101003492_ugoira0.png"

mikf added a commit that referenced this issue Sep 6, 2024
- introduce '_ugoira_frame_index' metadata field
- store Ugoira file exts separately
- add 'skip' option
@mikf mikf closed this as completed Sep 29, 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

2 participants