Veneomin
@Veneomin

Как работать с буфером в nodejs?

У меня вот такой код, который делает мне штрих код и сохраняет его в директорию. Но после выполнения скрипт "висит". Как его завершить после сохранения файла?
function createImage() {
        bwipjs.toBuffer({
            bcid:        'code128',       // Barcode type 
            text:        '0123456789',    // Text to encode 
            scale:       3,               // 3x scaling factor 
            height:      10,              // Bar height, in millimeters 
            includetext: true,            // Show human-readable text 
            textxalign:  'center',        // Always good to set this 
            //textfont:    'Inconsolata',   // Use your custom font 
            textsize:    13               // Font size, in points 
        }, function (err, png) {
            if (err) {
                console.log(err)
                // Decide how to handle the error 
                // `err` may be a string or Error object 
            } else {

                fs.writeFile('images/test.png', png, function(err) {

                });
                // `png` is a Buffer 
                // png.length           : PNG file length 
                // png.readUInt32BE(16) : PNG image width 
                // png.readUInt32BE(20) : PNG image height 
            }
        });
    }
  • Вопрос задан
  • 249 просмотров
Решения вопроса 1
@yociyavi
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы