Skip to content

Instantly share code, notes, and snippets.

@AndreasFurster
Created September 11, 2026 08:03
Show Gist options
  • Select an option

  • Save AndreasFurster/222a216ec6f664225dca06808e015e97 to your computer and use it in GitHub Desktop.

Select an option

Save AndreasFurster/222a216ec6f664225dca06808e015e97 to your computer and use it in GitHub Desktop.
Downloads test images in different resolutions from picsum.photos
const fs = require('fs');
(async () => {
const amount = 10;
const sizes = [
{ name: '1080p-l', width: 1920, height: 1080 },
{ name: '1080p-p', width: 1080, height: 1920 },
{ name: '4k-l', width: 3840, height: 2160 },
{ name: '4k-p', width: 2160, height: 3840 },
]
const path = './images/';
if (!fs.existsSync(path)) {
fs.mkdirSync(path);
}
for (let s = 0; s < sizes.length; s++) {
for (let i = 1; i < amount + 1; i++) {
const size = sizes[s];
const url = `https://picsum.photos/${size.width}/${size.height}`;
const filename = `${path}${size.name}-${i}.jpg`;
const response = await fetch(url);
const arrayBuffer = await response.arrayBuffer();
const buffer = Buffer.from(arrayBuffer);
fs.writeFile(filename, buffer, () => {
console.log(`Downloaded ${filename}`);
});
}
}
}
)();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment