Skip to content

Commit

Permalink
v23.7.21
Browse files Browse the repository at this point in the history
  • Loading branch information
torn4dom4n committed Jul 21, 2023
1 parent b123c61 commit 32ecc7b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pnpm install
Now, remove example images then copy your images into `images` folder and run:

```sh
node index.js
node index.mjs
```

The `images.json` file will contain an array of objects, where each object represents an image. The objects will have the following properties:
Expand Down
2 changes: 1 addition & 1 deletion index.js → index.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'node:fs/promises';
import { getImages } from './lib/getImages.js';
import { getImages } from './src/getImages.mjs';

// Get all images inside the folder images
const images = await getImages('images/*.{jpg,png}');
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "@area44/getimages",
"description": "Get all images in a directory and write them to a JSON file",
"version": "23.7.10",
"version": "23.7.21",
"private": "true",
"type": "module",
"author": "AREA44",
"repository": {
"url": "git+https://github.com/AREA44/node-getImages.git"
Expand All @@ -18,5 +17,5 @@
"engines": {
"node": ">=18"
},
"packageManager": "pnpm@8.6.7"
"packageManager": "pnpm@8.6.9"
}
4 changes: 2 additions & 2 deletions lib/getImages.js → src/getImages.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { getPlaiceholder } from 'plaiceholder';

export async function getImages(pattern) {
const images = await Promise.all(
glob.sync(pattern).map(async (file) => {
const src = file.replace('\\', '/');
glob.sync(pattern, { posix: true }).map(async (file) => {
const src = file.replace('images/', '');
const buffer = await fs.readFile(file);
const {
metadata: { height, width },
Expand Down

0 comments on commit 32ecc7b

Please sign in to comment.