Skip to content

Instantly share code, notes, and snippets.

@Krazete
Last active November 17, 2018 21:46
Show Gist options
  • Save Krazete/d4482119ff3cb42ca3e0da5d24a20b0b to your computer and use it in GitHub Desktop.
Save Krazete/d4482119ff3cb42ca3e0da5d24a20b0b to your computer and use it in GitHub Desktop.
Download Pixiv Canvas-Based Animated Images and Generate its Sprite Sheet
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();
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