Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/418.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用node.js比较两个对象_Javascript_Node.js_Imagemagick - Fatal编程技术网

Javascript 使用node.js比较两个对象

Javascript 使用node.js比较两个对象,javascript,node.js,imagemagick,Javascript,Node.js,Imagemagick,我试图使用node.js比较两个对象。 ie在下面的代码中比较了功能和特性1 var im = require('imagemagick'); var fs = require("fs"); im.identify('/home/ushu/dev/filesize/colorlaser-246154946-output.pdf', function(err, features) { if (err) throw err; console.log(features); im.ide

我试图使用
node.js
比较两个对象。 ie在下面的代码中比较了功能和特性1

var im = require('imagemagick');

var fs = require("fs");

im.identify('/home/ushu/dev/filesize/colorlaser-246154946-output.pdf', function(err, features) {
  if (err) throw err;
  console.log(features);
  im.identify('/home/ushu/dev/filesize/test.pdf', function(err, features1) {
    if (err) throw err;
    console.log("-------------------------------------------------")
    console.log(features1);
    if (features != features1) {
      console.log("not eqqq")
    }
  });
}))

console.log(功能)
打印以下值

{ '2': '( 3084, 3084, 3084,65535) #0C0C0C0C0C0C rgba(12,12,12,1)',
  '4': '(62451,62451,62451,65535) #F3F3F3F3F3F3 rgba(243,243,243,1)',
    '389490': '(65535,65535,65535,65535) #FFFFFFFFFFFF white'
  format: 'PDF',
  class: 'DirectClass',
  geometry: '612x792+0+0',
  resolution: '72x72',
  'print size': '8.5x11',
  units: 'Undefined',
  type: 'PaletteMatte',
  endianess: 'Undefined',
  colorspace: 'RGB',
  depth: 16,
  'channel depth': { red: '8-bit', green: '8-bit', blue: '8-bit', alpha: '1-bit' },
  'channel statistics': 
   { red: 
      { min: '0 (0)',
        max: '65535 (1)',
        mean: '60171.8 (0.918163)',
        'standard deviation': '15774.2 (0.240699)',
        kurtosis: '7.43399',
        skewness: '-2.96721' },
     green: 
      { min: '0 (0)',
        max: '65535 (1)',
        mean: '60171.8 (0.918163)',
        'standard deviation': '15774.2 (0.240699)',
        kurtosis: '7.43399',
        skewness: '-2.96721' }
     },
  'image statistics': 
   { overall: 
      { min: '0 (0)',
        max: '65535 (1)',
        mean: '44566.9 (0.680048)',
        'standard deviation': '14064.6 (0.214613)',
        kurtosis: '28.682',
        skewness: '-6.99615' } },
  histogram: 
   { '34': '( 2313, 2313, 2313,65535) #090909090909 rgba(9,9,9,1)',
     '289': '( 1799, 1799, 1799,65535) #070707070707 rgba(7,7,7,1)',
     '5755': '(    0,    0,    0,65535) #000000000000 black' },
  'rendering intent': 'Undefined',
  interlace: 'None',
  'background color': 'white',
  'border color': 'rgba(223,223,223,1)',
  'matte color': 'grey74',
  'transparent color': 'none',
  compose: 'Over',
  'page geometry': '612x792+0+0',
  dispose: 'Undefined',
  iterations: '0',
  compression: 'Undefined',
  orientation: 'Undefined',
  properties: 
   { 'date:create': '2014-10-28T12:18:40+06:00',
     'date:modify': '2014-10-28T12:18:40+06:00',
     'pdf:hiresboundingbox': '612x792+0+0',
     'pdf:version': 'PDF-1.3',
     signature: '3a281605e05aa1bd74105887caeaddda4dfac3c78716ac9d1309f3570e4c2368' },
  profiles: 
   { 'profile-icc': '2576 bytes',
     'artifex software srgb icc profile': {} },
  artifacts: { verbose: 'true' },
  tainted: 'False',
  filesize: '59.2KBB',
  'number pixels': '485KB',
  'pixels per second': '48.47MB',
  'user time': '0.020u',
  'elapsed time': '0:01.010',
  version: 'ImageMagick 6.6.9-7 2012-08-17 Q16 http://www.imagemagick.org',
  width: 612,
  height: 792 }

console.log(功能1)
打印

{ '499911': '(65535,65535,65535,    0) #FFFFFFFFFFFF0000 rgba(255,255,255,0)',
  format: 'PDF',
  class: 'DirectClass',
  geometry: '596x842+0+0',
  resolution: '72x72',
  'print size': '8.27778x11.6944',
  units: 'Undefined',
  type: 'Bilevel',
  'base type': 'Bilevel',
  endianess: 'Undefined',
  colorspace: 'RGB',
  depth: 16,
  'channel depth': { gray: '1-bit', alpha: '4-bit' },
  'channel statistics': 
   { gray: 
      { min: '0 (0)',
        max: '65535 (1)',
        mean: '65284.1 (0.996172)',
        'standard deviation': '4046.92 (0.0617521)',
        kurtosis: '256.239',
        skewness: '-16.0698' },
     alpha: 
      { min: '0 (0)',
        max: '65535 (1)',
        mean: '199.892 (0.00305016)',
        'standard deviation': '3454.01 (0.0527048)',
        kurtosis: '329.769',
        skewness: '-18.0427' } },
  alpha: 'rgba(255,255,255,0)   #FFFFFFFFFFFF0000',
  histogram: 
   { '18': '(    0,    0,    0,43690) #000000000000AAAA rgba(0,0,0,0.666667)',
     '24': '(    0,    0,    0,26214) #0000000000006666 rgba(0,0,0,0.4)'
      },
  'rendering intent': 'Undefined',
  interlace: 'None',
  'background color': 'white',
  'border color': 'rgba(223,223,223,1)',
  'matte color': 'grey74',
  'transparent color': 'none',
  compose: 'Over',
  'page geometry': '596x842+0+0',
  dispose: 'Undefined',
  iterations: '0',
  compression: 'Undefined',
  orientation: 'Undefined',
  properties: 
   { 'date:create': '2014-10-28T12:18:41+06:00',
     'date:modify': '2014-10-28T12:18:41+06:00',
     'pdf:hiresboundingbox': '596x842+0+0',
     'pdf:version': 'PDF-1.4',
     signature: '63e1cbdcc1568c376cb5f8612f4034de008add9fe8492e4d378ea176cb8e2eab' },
  profiles: 
   { 'profile-icc': '2576 bytes',
     'artifex software srgb icc profile': {} },
  artifacts: { verbose: 'true' },
  tainted: 'False',
  filesize: '8.21KBB',
  'number pixels': '502KB',
  'pixels per second': '50.18MB',
  'user time': '0.010u',
  'elapsed time': '0:01.009',
  version: 'ImageMagick 6.6.9-7 2012-08-17 Q16 http://www.imagemagick.org',
  width: 596,
  height: 842 }
这些打印值不相等


使用
node.js
如何比较这些输出值是否相等

如果两个对象引用内存中的同一对象,即使这两个对象在其他方面相同,在相等检查中也将返回相等!因此,您必须根据属性比较这两个对象

您可以使用来比较两个对象。以下是lodash文件中的一个示例:

var _ = require('lodash');
var object = { 'name': 'fred' };
var copy = { 'name': 'fred' };

object == copy;
// → false

_.isEqual(object, copy);
// → true
您可以使用“下划线”包来比较两个对象