2017-01-25 13 views
1

このBackground image thumbnail processing with Azure Functions and NodeJSの記事を使用してサムネイル画像を作成しました。画像は正常に作成されました。画像のサイズが増えました。それは非常に小さい必要がありますか?この奇妙な問題を解決するにはどうすればよいですか?アズール関数、サムネイル画像のサイズが元の画像よりも大きい

これは、BLOBストレージ

enter image description here

enter image description here

enter image description here

に原画像が処理の後で(サムネイル画像)

enter image description here

enter image description here

enter image description here

これは、Azureの機能(ノード)である:私はこのための解決策を見つけた

var Jimp = require("jimp"); 

module.exports = (context, myBlob) => { 

    // Read image with Jimp 
    Jimp.read(myBlob).then((image) => { 

     // Manipulate image 
     image 
      .resize(200, Jimp.AUTO) 
      .greyscale() 
      .getBuffer(Jimp.MIME_JPEG, (error, stream) => { 

       // Check for errors 
       if (error) { 
        context.log(`There was an error processing the image.`); 
        context.done(error); 
       } 
       else { 
        context.log(`Successfully processed the image`); 

        // Bind the stream to the output binding to create a new blob 
        context.done(null, stream); 

       } 

      }); 

    }); 

}; 
+1

これは、より多くのJimpの問題です。あなたはこのイメージであなたの地元でそれをテストすることができます。 –

+0

コンテンツタイプが一致しません。 Blobストレージは、コンテンツタイプに基づいて異なるものを格納する可能性があります。 –

+0

ありがとう、@ AaronChen-MSFT私は解決策を見つけました。それを参照してください:) – Sampath

答えて

1

JPEGファイルのデフォルトの品質はあなたが圧縮を得るために下に何か に設定する必要があります100です:

あなたはここでそれについての詳細を読むことができます:Image is resized down and gets bigger file size

を私は.quality(50)を設定する必要がこの問題はJPEGsでのみ発生します。

var Jimp = require("jimp"); 

module.exports = (context, myBlob) => { 

    // Read image with Jimp 
    Jimp.read(myBlob).then((image) => { 

     // Manipulate image 
     image 
      .resize(200, Jimp.AUTO) 
      .greyscale() 
      .quality(50) // set the quality for JPEGs 
      .getBuffer(Jimp.MIME_JPEG, (error, stream) => { 

       // Check for errors 
       if (error) { 
        context.log(`There was an error processing the image.`); 
        context.done(error); 
       } 
       else { 
        context.log(`Successfully processed the image`); 
        // Bind the stream to the output binding to create a new blob 
        context.done(null, stream); 

       } 

      }); 

    }); 

}; 
関連する問題