Created
March 9, 2020 16:36
-
-
Save transitive-bullshit/05bc1f66dca13c78a36ec64b08c80e22 to your computer and use it in GitHub Desktop.
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
const axios = require('axios'); | |
async function main () { | |
const getImg = (url) => { | |
return axios.get(url, { responseType: 'arraybuffer' }); | |
} | |
const url = 'https://octodex.github.com/images/original.png'; | |
const original = await getImg(url); | |
console.log('original', { status: original.status, size: original.data.length }); | |
const optimized = await axios.post('https://ssfy.sh/dev/imagemin/optimizeImage', original.data, { | |
headers: { | |
'Content-Type': 'application/octet-stream' | |
}, | |
responseType: 'arraybuffer' | |
}); | |
console.log('optimized', { status: optimized.status, size: optimized.data.length }); | |
return optimized; | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment