Last active
January 18, 2025 01:35
-
-
Save trey/fed51ef90fbc546059e84eceae7e8eea to your computer and use it in GitHub Desktop.
Revisions
-
trey revised this gist
Jun 28, 2020 . No changes.There are no files selected for viewing
-
trey revised this gist
Jun 28, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,4 +3,4 @@ <figcaption> {% exifData image %} </figcaption> </figure> -
trey revised this gist
Jun 28, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,7 +31,7 @@ module.exports = async(src) => { // where it exists and makes sense. for (const [key, value] of items) { if (value) { markup += `<div>${key}: ${value}</div>`; } } -
trey revised this gist
Jun 28, 2020 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ const responsiveImage = require('./src/_includes/shortcodes/responsive-image'); const exifData = require('./src/_includes/shortcodes/exif-data'); // … -
trey revised this gist
Jun 28, 2020 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ <figure> {% responsiveImage image %} <figcaption> {% exifData image %} </figcaption> </figure> -
trey revised this gist
Jun 28, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ module.exports = async (src, alt, title, width, height) => { }; if (alt === undefined) { // Pull in Exif data if we don’t have alt text. const altText = await exif.read(`${options.inputDir}/${src}`).then( exifData => exifData.image.ImageDescription ); -
trey revised this gist
Jun 28, 2020 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ const exif = require('fast-exif'); const imgFolder = 'src/img/gallery/'; module.exports = async(src) => { const path = imgFolder + src; @@ -18,18 +18,18 @@ module.exports = async(src) => { : `Photo from ${DateTime.getFullYear()}`; // Create an object with the items we want. const items = Object.entries({ Year: DateTime.getFullYear(), Camera: `${exifData.image.Make} ${exifData.image.Model}`, Caption: imgDescription, 'ƒ/stop': exifData.exif.FNumber, Shutter: !(isNaN(exifData.exif.ExposureTime)) ? `1/${1 / exifData.exif.ExposureTime}` : null, 'ISO': exifData.exif.ISO, }); // Loop through the objects one by one and only include output // where it exists and makes sense. for (const [key, value] of items) { if (value) { markup += `<div>${key}: ${value}<div>`; } -
trey revised this gist
Jun 28, 2020 . 2 changed files with 46 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,8 @@ const exifData = require('./src/_includes/shortcodes/exif-data'); module.exports = function(eleventyConfig) { // … eleventyConfig.addShortcode('responsiveImage', responsiveImage); eleventyConfig.addShortcode('exifData', exifData); // … This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ const Image = require('@11ty/eleventy-img'); const exif = require('fast-exif'); module.exports = async (src, alt, title, width, height) => { const options = { inputDir: 'src/img/gallery', outputDir: 'dist/img/gallery', urlPath: '/img/gallery', widths: [800, 1600, 2200, null], formats: 'jpeg', }; if (alt === undefined) { // Pull in EXIF data if we don't have alt text. const altText = await exif.read(`${options.inputDir}/${src}`).then( exifData => exifData.image.ImageDescription ); if (altText) { alt = altText; } else { throw new Error(`Missing alt on responsiveImage from: ${src}`); } } let stats = await Image(`${options.inputDir}/${src}`, options); let lowestSrc = stats.jpeg[0]; let titleAttribute = (title) ? `title="${title}"` : ''; let props = stats[options.formats].pop(); // If sizes are passed in, use them. Otherwise, analyze the files. let definedWidth = (width) ? width : props.width; let definedHeight = (height) ? height : props.height; const imgTag = `<img ${titleAttribute} alt="${alt}" src="${lowestSrc.url}" width="${definedWidth}" height="${definedHeight}" srcset="${stats.jpeg.map(entry => `${entry.url} ${entry.width}w`)}" />`; // Remove extraneous spaces and newlines. return imgTag.replace(/\n/g, '').replace(/\s+/g, ' '); }; -
trey revised this gist
Jun 27, 2020 . 1 changed file with 14 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,13 @@ const exif = require('fast-exif'); const imgFolder = ''; module.exports = async(src) => { const path = imgFolder + src; const imageData = await exif.read(path).then(exifData => { let DateTime; let markup = ''; if (exifData.exif.DateTimeDigitized) { DateTime = new Date(exifData.exif.DateTimeDigitized); } else { @@ -17,22 +18,21 @@ module.exports = async(src) => { : `Photo from ${DateTime.getFullYear()}`; // Create an object with the items we want. const entries = Object.entries({ Year: DateTime.getFullYear(), Camera: `${exifData.image.Make} ${exifData.image.Model}`, Caption: imgDescription, 'ƒ/stop': exifData.exif.FNumber, Shutter: isNaN(exifData.exif.ExposureTime) ? null : `1/${1 / exifData.exif.ExposureTime}`, 'ISO': exifData.exif.ISO, }); // Loop through the objects one by one and only include output // where it exists and makes sense. for (const [key, value] of entries) { if (value) { markup += `<div>${key}: ${value}<div>`; } } return markup; -
trey revised this gist
Jun 27, 2020 . 1 changed file with 7 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,6 @@ module.exports = async(src) => { const path = imgFolder + src; const imageData = await exif.read(path).then(exifData => { let DateTime; if (exifData.exif.DateTimeDigitized) { @@ -29,15 +28,14 @@ module.exports = async(src) => { 'ISO': exifData.exif.ISO, }; const entries = Object.entries(items); let markup = ''; for (const [key, value] of entries) { markup += `<div>${key}: ${value}<div>`; } return markup; }).catch(console.error); return imageData; -
trey revised this gist
Jun 26, 2020 . 1 changed file with 17 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,8 @@ module.exports = async(src) => { const path = imgFolder + src; const imageData = await exif.read(path).then(exifData => { // console.log('exifData', exifData); let DateTime; if (exifData.exif.DateTimeDigitized) { DateTime = new Date(exifData.exif.DateTimeDigitized); @@ -15,8 +17,23 @@ module.exports = async(src) => { ? exifData.image.ImageDescription : `Photo from ${DateTime.getFullYear()}`; // Create an object with the items we want. // Loop through the objects one by one and only include output // where it exists and makes sense. const items = { year: DateTime.getFullYear(), camera: `${exifData.image.Make} ${exifData.image.Model}`, caption: imgDescription, 'ƒ/stop': exifData.exif.FNumber, shutter: isNaN(exifData.exif.ExposureTime) ? null : `1/${1 / exifData.exif.ExposureTime}`, 'ISO': exifData.exif.ISO, }; console.log('items', items); return ` <div>year: ${DateTime.getFullYear()}</div> <div>camera: ${exifData.image.Make} ${exifData.image.Model}</div> <div>caption: ${imgDescription}</div> <div>fstop: ${exifData.exif.FNumber}</div> <div>shutter: 1/${1/exifData.exif.ExposureTime}</div> -
trey revised this gist
Jun 25, 2020 . 1 changed file with 10 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,17 +11,17 @@ module.exports = async(src) => { } else { DateTime = new Date(exifData.exif.DateTimeOriginal); } const imgDescription = (exifData.image.ImageDescription) ? exifData.image.ImageDescription : `Photo from ${DateTime.getFullYear()}`; return ` <div>year: ${DateTime.getFullYear()}</div> <div>caption: ${imgDescription}</div> <div>fstop: ${exifData.exif.FNumber}</div> <div>shutter: 1/${1/exifData.exif.ExposureTime}</div> <div>iso: ${exifData.exif.ISO}</div>`; }).catch(console.error); return imageData; }; -
trey revised this gist
Jun 25, 2020 . 1 changed file with 11 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ const exifData = require('./src/_includes/shortcodes/exif-data'); // … module.exports = function(eleventyConfig) { // … eleventyConfig.addShortcode('exifData', exifData); // … } -
trey created this gist
Jun 25, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ const exif = require('fast-exif'); const imgFolder = 'src/img/gallery/'; module.exports = async(src) => { const path = imgFolder + src; const imageData = await exif.read(path).then(exifData => { let DateTime; if (exifData.exif.DateTimeDigitized) { DateTime = new Date(exifData.exif.DateTimeDigitized); } else { DateTime = new Date(exifData.exif.DateTimeOriginal); } return { height: exifData.exif.PixelYDimension, width: exifData.exif.PixelXDimension, year: DateTime.getFullYear(), caption: exifData.image.ImageDescription || `Photo from ${DateTime.getFullYear()}`, fstop: exifData.exif.FNumber, shutter: 1 / exifData.exif.ExposureTime, iso: exifData.exif.ISO, }; }).catch(console.error); console.log('imageData', imageData); }; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ <figure> {% comment %} Put an image here {% endcomment %} <figcaption> {% exifData 'whatever.jpg' %} </figcaption> </figure>