sharp require sharp img sharp box_test tiff img metadata error metadat

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
sharp = require 'sharp'
img = sharp('box_test.tiff')
img.metadata (error, metadata) ->
boxes.map (box, n) ->
x = box[0]
y = metadata.height - box[3]
width = box[2] - box[0]
height = box[3] - box[1]
img.extract(y, x, width, height)
.toFormat('png')
.toFile(path.join('train_data', n + '_' + box[4] + '.png'))