ppi

Find the PPI (pixels per inch) of an image.

  • 所有者: matthewmueller/ppi
  • 平台:
  • 許可證:
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

ppi

Find the PPI (pixels per inch) of an image.

Example

var PPI = require('ppi');
var parse = require('exif2');
var exif = parse('./photo.png');

var ppi = PPI(exif);

API

ppi(exif)

Determine the PPI of an image. If it cannot find the PPI, ppi returns false.

Support

Parsing exif data is not trivial. There are many different formats and lots of pictures (especially those from the internet) do not have enough data to determine the PPI.

This library is a test-driven approach to determining the PPI on a variety of pictures. Right now this library tests the following image sources:

ppi(exif)
  should find ppi of:
    ✓ retina screenshot from mac
    ✓ photo from an iphone 4
    ✓ photo from an iphone 5s
    ✓ photo from an ipad 3
    ✓ photo from an samsung s3
    ✓ photo from a camera (leica)
    ✓ screenshot from windows
  should not find ppi of:
    ✓ old photo from the internet
    ✓ screenshot from ubuntu
    ✓ screenshot from ipad 3
    ✓ screenshot from iphone 5s

To test a photo from your device simply add it to test/images, run the tests with make test, then inspect the exif data inside test/exif. Hopefully there will be enough data to determine the PPI.

TODO

Depending on what kind of computer the screenshot was taken on the PPI will change:

  • Non-retina mac: 72 ppi
  • Retina mac: 144 ppi
  • Windows: 96 ppi
  • Linux: 96 ppi (?)

We can provide sensible defaults for images that we know are taken on a specific computer

Test

make test

License

(The MIT License)

Copyright (c) 2012 Matthew Mueller <mattmuelle@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

概覽

名稱與所有者matthewmueller/ppi
主編程語言JavaScript
編程語言JavaScript (語言數: 1)
平台
許可證
發布數0
創建於2013-10-13 18:55:54
推送於2013-10-15 18:14:40
最后一次提交2013-10-15 11:14:31
星數34
關注者數5
派生數1
提交數11
已啟用問題?
問題數3
打開的問題數3
拉請求數0
打開的拉請求數0
關閉的拉請求數0
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?
去到頂部