Skip to content

Instantly share code, notes, and snippets.

@benursu
Created August 23, 2021 17:44
Show Gist options
  • Save benursu/2fb6b91873d597f627417fcda0dd3139 to your computer and use it in GitHub Desktop.
Save benursu/2fb6b91873d597f627417fcda0dd3139 to your computer and use it in GitHub Desktop.
Convert Equirectangular to Cubemap
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// Convert Equirectangular to Cubemap
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// require
const {convertImage} = require('panorama-to-cubemap')
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// file name
const url = 'PIC_20210525_044252.jpg'
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// go!
// url should be absolute local path or image link
// This will generate a 6 files in local directory
convertImage(url)
// these are default options
const options = {
rotation : 180,
interpolation : 'lanczos',
outformat : 'jpg',
outtype : 'file',
width : Infinity
}
// for custom options
/*
rotation should 0 - 360 DEFAULT: 180
interpolation
lanczos DEFAULT
linear
cubic
nearest
outformat
jpg DEFAULT
png
outtype
file (this will generate a 6 files in local) DEFAULT
buffer (output type wiil be in buffer)
width
orginal file width /4 DEFAULT
custom value should be less than that
*/
// custom option will give promise response
convertImage(url,options).then(x=>{
// output will be buffer or file based on input
console.log(x)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment