1
0
mirror of https://github.com/kremalicious/blog.git synced 2025-01-03 18:35:07 +01:00

exif fixes

This commit is contained in:
Matthias Kretschmann 2018-09-12 22:36:50 +02:00
parent 5d5e8dc3a5
commit 184078231f
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 5 additions and 10 deletions

View File

@ -4,6 +4,7 @@ const yaml = require('js-yaml')
const { createFilePath } = require('gatsby-source-filesystem') const { createFilePath } = require('gatsby-source-filesystem')
const { paginate } = require('gatsby-awesome-pagination') const { paginate } = require('gatsby-awesome-pagination')
const fastExif = require('fast-exif') const fastExif = require('fast-exif')
const { Fraction } = require('fractional')
const meta = yaml.load(fs.readFileSync('./content/meta.yml', 'utf8')) const meta = yaml.load(fs.readFileSync('./content/meta.yml', 'utf8'))
const { itemsPerPage } = meta const { itemsPerPage } = meta
@ -60,11 +61,6 @@ exports.onCreateNode = ({ node, actions, getNode }) => {
} }
} }
const getFraction = decimal => {
for (var denominator = 1; (decimal * denominator) % 1 !== 0; denominator++);
return { numerator: decimal * denominator, denominator: denominator }
}
const generateExif = (exifData, createNodeField, node) => { const generateExif = (exifData, createNodeField, node) => {
const { Model } = exifData.image const { Model } = exifData.image
const { const {
@ -75,14 +71,13 @@ const generateExif = (exifData, createNodeField, node) => {
ExposureBiasValue ExposureBiasValue
} = exifData.exif } = exifData.exif
const shutterspeedNumerator = getFraction(ExposureTime).numerator const { numerator, denominator } = new Fraction(ExposureTime)
const shutterspeedDenominator = getFraction(ExposureTime).denominator
const exposureShortened = parseFloat(ExposureBiasValue.toFixed(2)) const exposureShortened = parseFloat(ExposureBiasValue.toFixed(2))
const model = Model const model = `${Model}`
const iso = `ISO ${ISO}` const iso = `ISO ${ISO}`
const fstop = `ƒ ${FNumber}` const fstop = `ƒ ${FNumber}`
const shutterspeed = `${shutterspeedNumerator}/${shutterspeedDenominator}s` const shutterspeed = `${numerator}/${denominator}s`
const focalLength = `${FocalLength}mm` const focalLength = `${FocalLength}mm`
let exposure let exposure

View File

@ -23,6 +23,7 @@
], ],
"dependencies": { "dependencies": {
"fast-exif": "^1.0.1", "fast-exif": "^1.0.1",
"fractional": "^1.0.0",
"gatsby": "^2.0.0-rc.21", "gatsby": "^2.0.0-rc.21",
"gatsby-awesome-pagination": "^0.1.1", "gatsby-awesome-pagination": "^0.1.1",
"gatsby-image": "^2.0.0-rc.2", "gatsby-image": "^2.0.0-rc.2",

View File

@ -36,7 +36,6 @@
///////////////////////////////////// /////////////////////////////////////
.type { .type {
margin-bottom: $spacer / 2;
text-align: center; text-align: center;
a { a {