mozilla / tippy-top-sites-deprecated

[deprecated][unmaintained]
6 stars 7 forks source link

add IMAGE_SIZE constant exported #58

Closed k88hudson closed 7 years ago

pdehaan commented 7 years ago

FWIW, it looks like a few images aren't 128x128. Not sure if those will cause issues:

const { readdir } = require('fs');
const { join } = require('path');
const fastimage = require('fastimage');

const IMAGE_DIR = 'images';

readdir(IMAGE_DIR, (err, images) => {
  if (err) throw err;
  const promises = images.map((image) => fastimage.info(join(IMAGE_DIR, image))
      .then(({path, size, width, height}) => ({ path, size, width, height })));

  Promise.all(promises)
    .then((images) => {
      images.filter((image) => (image.width !== 128) || (image.height !== 128))
        .forEach((image) => console.log(`${image.width}x${image.height}: ${image.path}`));
      });
});

/* OUTPUT:
  64x64:   images/dailybeast-com.png
  64x64:   images/dailymail-co-uk.png
  64x64:   images/espn-go-com.png
  64x64:   images/images-google-com.png
  64x64:   images/jcpenney-com.png
  106x128: images/verizonwireless-com.png
  64x64:   images/wikia-com.png
*/
pdehaan commented 7 years ago

Not sure if we want to add tests for 128x128 image sizes:

      it("should have 128x128 images", (done) => {
        const imagePath = join("images", site.image_url);
        fastimage.info(imagePath, (err, { width, height }) => {
          assert.isNull(err);
          assert.equal(width, 128, `${site.image_url} to have width of 128`);
          assert.equal(height, 128, `${site.image_url} to have height of 128`);
          done();
        });
      });
  1) top_sites #41 dailymail should have 128x128 images:
     Uncaught AssertionError: dailymail-co-uk.png to have width of 128: expected 64 to equal 128
      at fastimage.info (test/index.test.js:57:18)
      at done (node_modules/fastimage/lib/core.js:286:11)
      at imageSize (node_modules/fastimage/lib/core.js:162:12)
      at node_modules/image-size/lib/index.js:96:7
      at node_modules/image-size/lib/index.js:49:9
      at FSReqWrap.oncomplete (fs.js:112:15)

  2) top_sites #42 dailybeast should have 128x128 images:
     Uncaught AssertionError: dailybeast-com.png to have width of 128: expected 64 to equal 128
      at fastimage.info (test/index.test.js:57:18)
      at done (node_modules/fastimage/lib/core.js:286:11)
      at imageSize (node_modules/fastimage/lib/core.js:162:12)
      at node_modules/image-size/lib/index.js:96:7
      at node_modules/image-size/lib/index.js:49:9
      at FSReqWrap.oncomplete (fs.js:112:15)

  3) top_sites #88 images.google should have 128x128 images:
     Uncaught AssertionError: images-google-com.png to have width of 128: expected 64 to equal 128
      at fastimage.info (test/index.test.js:57:18)
      at done (node_modules/fastimage/lib/core.js:286:11)
      at imageSize (node_modules/fastimage/lib/core.js:162:12)
      at node_modules/image-size/lib/index.js:96:7
      at node_modules/image-size/lib/index.js:49:9
      at FSReqWrap.oncomplete (fs.js:112:15)

  4) top_sites #103 jcpenney should have 128x128 images:
     Uncaught AssertionError: jcpenney-com.png to have width of 128: expected 64 to equal 128
      at fastimage.info (test/index.test.js:57:18)
      at done (node_modules/fastimage/lib/core.js:286:11)
      at imageSize (node_modules/fastimage/lib/core.js:162:12)
      at node_modules/image-size/lib/index.js:96:7
      at node_modules/image-size/lib/index.js:49:9
      at FSReqWrap.oncomplete (fs.js:112:15)

  5) top_sites #175 verizonwireless should have 128x128 images:
     Uncaught AssertionError: verizonwireless-com.png to have width of 128: expected 106 to equal 128
      at fastimage.info (test/index.test.js:57:18)
      at done (node_modules/fastimage/lib/core.js:286:11)
      at imageSize (node_modules/fastimage/lib/core.js:162:12)
      at node_modules/image-size/lib/index.js:96:7
      at node_modules/image-size/lib/index.js:49:9
      at FSReqWrap.oncomplete (fs.js:112:15)

  6) top_sites #184 wikia should have 128x128 images:
     Uncaught AssertionError: wikia-com.png to have width of 128: expected 64 to equal 128
      at fastimage.info (test/index.test.js:57:18)
      at done (node_modules/fastimage/lib/core.js:286:11)
      at imageSize (node_modules/fastimage/lib/core.js:162:12)
      at node_modules/image-size/lib/index.js:96:7
      at node_modules/image-size/lib/index.js:49:9
      at FSReqWrap.oncomplete (fs.js:112:15)