I am using hapi v17.1 .I am not an expert programmer. I need to get the resolution of an image in hapi js for server side image validation .
I have tried image-size
plugin
var sizeOf = require('image-size');
var { promisify } = require('util');
var url = require('url');
var https = require('http');
................
// my code
................
const host = 'http://' + request.info.host + '/';
imageName = host + path;
try {
var options = url.parse(imageName);
https.get(options, function (response) {
var chunks = [];
response.on('data', function (chunk) {
chunks.push(chunk);
}).on('end', function () {
var buffer = Buffer.concat(chunks);
console.log("image height and width = ",sizeOf(buffer));
});
});
} catch (err) {
console.log('error occured = ', err);
}
for http it is working fine but I cant do it for https
when I tried for https url
and showing the error
error occured = TypeError: https.get is not a function
at handler (/home/jeslin/projects/hapi/gg-admin/app/controllers/web/advertisement.js:178:31)
at <anonymous>
how can I implement this for https
image url