Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

nodejs sharp change image to multiple sizes

// Sharp and FS module needed.
;(async function(){
	let imgBuffer = await sharp("./myimage.jpg").toBuffer()
    let thumbnail = await sharp(imgBuffer).resize(100, 100).toBuffer()
    let image = await sharp(imgBuffer).resize(1600, 900).toBuffer()
    fs.writeFile("./thumbnail.jpg", thumbnail, err => {
    	if(err) console.log(err)
    })
    fs.writeFile("./image.jpg", thumbnail, err => {
      if(err) console.log(err)
    })
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: cli run js 
Javascript :: javascript short syntax get element 
Javascript :: javascript curtocircuito 
Javascript :: jquery clear chozen 
Javascript :: javascript get browser is electron 
Javascript :: Portez ce vieux whisky au juge blond qui fume 
Javascript :: conflict paypal api javascript with user agent Mozilla/5.0 Google 
Javascript :: measure width in px chrome extension 
Javascript :: mdns javascript 
Javascript :: filtering array of friends javascript 
Javascript :: javascript Bingo add called number to a list 
Javascript :: Leaflet.KMLGroundOverlay kmz 
Javascript :: How can I display an image and text from an array on a webpage? Ask Question 
Javascript :: guardar en una variable la peticion ajax 
Javascript :: unable to communicate with the paypal gateway in magento 2 
Javascript :: json2csv parse with flatten example javascript 
Javascript :: useBootstrapPrefixhttp://localhost:8000/static/js/bundle.js:15261:75 
Javascript :: code in nested forEach loop- react native 
Javascript :: select xml child element with jQuery 
Javascript :: express pourquoi mettre bodyparser avant router 
Javascript :: universal apollo kit 
Javascript :: cannot find name json angular 7 
Javascript :: how to convert json to bootstrap treeview format 
Javascript :: gatsby underline link if page is active 
Javascript :: if property is same group javscript 
Javascript :: singly even magic square creation algorithm 
Javascript :: firebase realtime database query where number bigger 
Javascript :: most popular company with nodejs 
Javascript :: npm react router 6.0.0-alpha.2 
Javascript :: Uncaught ReferenceError: jQuery is not defined at (index): "405" 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =