UNPKG

string2png

Version:

Convert strings in various formats to tiny images

41 lines (29 loc) 823 B
module.exports = options function options( opt ) { let result = {} opt = opt || {} var channels = opt.channels || 'rgb' if ( 'number' == typeof channels ) { channels = parseInt( channels ) || 0 channels = 'rgba'.substr( 0, channels ) + '0'.repeat( Math.max( 0, channels - 4 ) ) } if ( 'string' == typeof channels ) { channels = channels.split('') } result.channels = channels if ( opt['normalize'] ) { result.normalize = parseInt( opt['normalize'] ) || channels.length } else { result.normalize = 0 } if ( opt['logarithmic'] ) { result.logarithmic = parseInt( opt['logarithmic'] ) || 1 } else { result.logarithmic = 0 } result.encoding = opt.encoding result.bytes = opt.bytes result.input = opt.input result.square = !!opt.square return result }