Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.


RunKit + npm: axios

node v14.20.1
version: 1.0.0
var axios = require("axios") var FormData = require('form-data'); // Get a buffer like yours from an online stock image const res = await axios.get('https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png', { responseType: 'arraybuffer'} ) const originalBuffer = Buffer.from(res.data, 'binary') console.log(originalBuffer) // Call the ClipDrop API const form = new FormData() form.append('image_file', originalBuffer, {contentType: "image/jpg", filename: "image.jpg"}) form.append('upscale', 2) const apiResponse = await axios.post('https://apis.clipdrop.co/super-resolution/v1', form, { headers: { 'x-api-key': 'REPLACE_THIS_WITH_YOUR_API_KEY', }, responseType: 'arraybuffer' }) const arrayBuffer = apiResponse.data const buffer = Buffer.from(arrayBuffer, 'binary') console.log(buffer)
Created from: https://npm.runkit.com/axios

no comments

    sign in to comment