Skip to content

Instantly share code, notes, and snippets.

@micycle1
Last active November 7, 2024 13:56
Show Gist options
  • Save micycle1/735006a338e4bea1a9c06377610886e7 to your computer and use it in GitHub Desktop.
Save micycle1/735006a338e4bea1a9c06377610886e7 to your computer and use it in GitHub Desktop.
Downloading full-size media from DeviantArt

For direct image URL, the image quality is much lower than the original upload (the resolution and size of the original upload can be found in the right sidebar). This is not the case few years ago when the original image was accessible through right click, but on 2017, Wix acquired DeviantArt, and has been migrating the images to their own image hosting system from the original DeviantArt system. They linked most of the direct images to a stripped-down version of the original images; hence the bad image quality. Below are the three different formats of direct image URLs I found:

  • URL with /v1/fill inside: this means that the image went through Wix's encoding system and is modified to a specific size and quality. In this case, you remove ?token= and its values, add /intermediary in front of /f/ in the URL, and change the image settings right after /v1/fill/ to w_5100,h_5100,bl,q_100. The definitions of the values can be found in Wix's Image Service, but basically, w_5100,h_5100 requests the width and height of the image to be 5100x5100 pixels, bl requires the baseline JPEG version, and q_100 sets the quality to 100% of the original. The reasons to have this dimension are: (1) 5100 pixels is the limit of the system; anything above it will result in 400 Bad Request. (2) according to the Wix's API:

    In case the required image is larger than the original, upscale should be enabled (lg_1) in order for a proportional upscale to be applied. If upscale is not enabled, the returned image will maintain the original size.

    Example: original URL vs modified URL. The original url has a file size of 153 KB and 1024x1280 resolution, while the modified URL has a file size of 2.03 MB and 2190x2738 resolution. The result is still not as good as the original upload (4.2 MB and 2700×3375 resolution), but this is the closest I can get

    UPDATE: for new uploads, this trick no longer works. However, the image quality can still be changed. To do this, you keep everything in the image URL the same and change the part q_\d+,strp to q_100

  • URL with /f/ but no /v1/fill inside: this is the original image, so just download it

  • URL with https://img\d{2} or https://pre\d{2}: this means that the image went through DeviantArt's system and is modified to a specific size. I could not figure out how to get the original image from these types of links, i.e. find https://orig\d{2} from them, so I just download the image as is

@brynnb
Copy link

brynnb commented Jun 1, 2023

Disclaimer: attempts below were done by a friend of mine, I'm only documenting his attempt. I did not attempt to access anything I am not authorized to access.

As of May 31, 2023, this doesn't seem to be working for my friend's image. The premise of the test was the artist is a friend of mine and was concerned about this workaround, so a second friend was testing for him to check. I am guessing there is some impact as to whether the image has any "Free download" button at all. The image tested with this method does not have it. Here are steps tried, all of them resulted in "bad path", "forbidden", "storage: object doesn't exist", or invalid token errors. Also here's the original link:

https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/lotofstuffhere.png/v1/fill/w_1280,h_854/somefilename.png?token=longtokenhere

Here's some of what was tried, not entirely exhaustive list:

  1. (add intermediary) https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/intermediary/f/lotofstuffhere.png/v1/fill/w_1280,h_854/somefilename.png?token=longtokenhere
  2. (change to 5100 etc) https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/intermediary/f/lotofstuffhere.png/v1/fill/w_5100,h_5100,bl,q_100/somefilename.png?token=longtokenhere
  3. (removed bl,q_100) https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/intermediary/f/lotofstuffhere.png/v1/fill/w_5100,h_5100/somefilename.png?token=longtokenhere
  4. (using the listed actual original dimensions) https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/intermediary/f/lotofstuffhere.png/v1/fill/w_3600,h_2400,bl,q_100/somefilename.png?token=longtokenhere
  5. (no token) https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/intermediary/f/lotofstuffhere.png/v1/fill/w_3600,h_2400,bl,q_100/somefilename.png
  6. Tried replacing the token with the one from a separate "Free download" image
  7. Tried modifying the token from an image that did have a "Free download" button, since the token itself also lists the filename that it's for. However modifying the token to have the correct filename threw either forbidden or invalid token errors (as expected)

A lot of variations on the above were also tried. Nothing seemed to work. So this is either patched, it doesn't work for some images (the ones without a free download button?), or my friend missed something here when attempting all this.

@RoL3aN
Copy link

RoL3aN commented Aug 29, 2023

Tested with an image from 2018. Works.

@Hunters20XX
Copy link

Hunters20XX commented Oct 10, 2023

I was gonna request anyone to just create an extension that has the download button enabled as always (even if some artists disabled it for security purposes), but I found this outdated extension from Chrome Strats.
Source: https://chrome-stats.com/d/kdcokocnkphjbaelobcehjokdleflnmj/download
Archive: https://www.4shared.com/folder/IhZnDOdu/DeviantArt_Downloader_OUTDATED.html

@micycle1
Copy link
Author

micycle1 commented Oct 10, 2023

If you decode the token from the URL query parameters as a JWT you'll see that wix puts limits on the width and height of the image that you can request there. Here is an example, I used jwt.io to decode...

Sadly if one tries to change the payload (remove the dimensions restrictions for instance) they encounter token validation failed, because the token contains a HMACSHA256 hash of the payload. Their system hashes the supplied payload with their private key and checks whether the hash supplied by the user equals the payload hash. Without knowing the private key, it's infeasible to come up with a valid hash for a modified payload.

@rarelygoeshere
Copy link

Can anyone test if this still works? Curious to know if it's still applicable.

@lingeringame
Copy link

I tested all methods mentioned in the thread for a 2018 deviantart image but nothing worked. As a workaround, you could check if the artist posts their work elsewhere where the image quality is not filtered down. Not at all code related, but figured most people would be interested.

@Mitradis
Copy link

Work

@Lt-knb
Copy link

Lt-knb commented Apr 6, 2024

URL with /f/ but no /v1/fill inside: this is the original image, so just download it

It says Unauthorized

@rudy128
Copy link

rudy128 commented Jul 8, 2024

It worked. Just Downloaded a 4k Background. Thanks mate!

@TheAlmightyStegosaurus
Copy link

I dont understand any of this

@anupamkumar
Copy link

does not work for newer images ... does work for older images ...

@lucas3520
Copy link

It seems it works for posts made before 2019. For posts after 2019, it says something akin to "storage: object does not exist"

But still, a huge thank you for this. It definitely helped with some of my favorite posts there.

@Dishman03
Copy link

This does still work for older images, but has anyone discovered a way to obtain the original res?

@szero
Copy link

szero commented Sep 13, 2024

tested on 2018 image and it worked tho my image had /v1/fit instead of /v1/fill in the url but it still worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment