Created
September 11, 2026 08:03
-
-
Save AndreasFurster/222a216ec6f664225dca06808e015e97 to your computer and use it in GitHub Desktop.
Downloads test images in different resolutions from picsum.photos
This file contains hidden or 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
| 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