Last active
November 17, 2018 21:46
-
-
Save Krazete/d4482119ff3cb42ca3e0da5d24a20b0b to your computer and use it in GitHub Desktop.
Download Pixiv Canvas-Based Animated Images and Generate its Sprite Sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var xhr = new XMLHttpRequest(); | |
xhr.open("GET", pixiv.context.ugokuIllustData.src, true); | |
xhr.responseType = "blob"; | |
xhr.onload = function() { | |
var blob = this.response; | |
var a = document.createElement("a"); | |
a.href = URL.createObjectURL(blob); | |
a.setAttribute("download", "compressed.zip"); | |
a.click(); | |
console.log(blob); | |
}; | |
xhr.send(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear; | |
folder = 'compressed'; | |
scale = 0.25; | |
files = dir(folder); | |
n = length(files); | |
for i = 1:n | |
file = files(i); | |
path = [file.folder, '/', file.name]; | |
if endsWith(path, 'jpg') | |
im = imread(path); | |
im = imresize(im, scale); | |
if exist('ims', 'var') | |
ims = [ims, im]; | |
else | |
ims = im; | |
end | |
end | |
end | |
imwrite(gray2rgb(ims), [folder, '.png']); | |
function rgb = gray2rgb(gray) | |
rgb = cat(3, gray, gray, gray); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment