Skip to content

Commit f6c4611

Browse files
authored
2.0 (#1)
* Added wildcard so that all typescript typings are included in NPM package * Refactoring * Added prettier and eslint * Refactoring * Added prettier and eslint * random changes * Fixing rollup config * Fixed exports * All tests passing * 2.0.14 * Updated IExifElement to allow any value * Updated package.json * 2.0.15 * Updated README * 2.0.16
1 parent 34e06b7 commit f6c4611

20 files changed

+3540
-2340
lines changed

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/dist/*
2+
/tests/*
3+
/lib/*

.eslintrc.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"parser": "@typescript-eslint/parser", // Specifies the ESLint parser
3+
"extends": [
4+
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin
5+
"prettier/@typescript-eslint", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
6+
"plugin:prettier/recommended"
7+
],
8+
"plugins": [
9+
"prettier"
10+
],
11+
"rules": {
12+
"@typescript-eslint/no-use-before-define": [
13+
"error",
14+
{
15+
"variables": false
16+
}
17+
],
18+
"@typescript-eslint/interface-name-prefix": 0,
19+
"prettier/prettier": [
20+
"error"
21+
]
22+
},
23+
"parserOptions": {
24+
"ecmaVersion": 2018, // Allows for the parsing of modern ECMAScript features
25+
"sourceType": "module" // Allows for the use of imports
26+
}
27+
}

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@ npm-debug.log
77
node_modules
88
dist
99
.rpt2_cache
10-
lib/
10+
11+
/dist
12+
13+
.vscode
14+
/lib

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/dist/*
2+
/tests/*
3+
/lib/*

.prettierrc

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"printWidth": 120,
2+
"semi": true,
33
"trailingComma": "all",
4-
"singleQuote": true
4+
"singleQuote": true,
5+
"tabWidth": 2
56
}

.vscode/settings.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"git.ignoreLimitWarning": true,
3+
"eslint.autoFixOnSave": true,
4+
"eslint.validate": [
5+
"javascript",
6+
{"language": "typescript", "autoFix": true },
7+
],
8+
"editor.formatOnSave": true,
9+
"[javascript]": {
10+
"editor.formatOnSave": false,
11+
},
12+
"[typescript]": {
13+
"editor.formatOnSave": false,
14+
},
15+
}

README.md

+52-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,62 @@
1-
Piexifjs
1+
Piexif-ts
22
========
33

4-
**Node.js** |**browser**
5-
-------------------------------------------------------------------------------------------------------------------|-----------
6-
[![Build Status](https://travis-ci.org/hMatoba/piexifjs.svg?branch=2.0)](https://travis-ci.org/hMatoba/piexifjs)|[![CircleCI](https://circleci.com/gh/hMatoba/piexifjs/tree/2.0.svg?style=svg)](https://circleci.com/gh/hMatoba/piexifjs/tree/2.0)
7-
84
This repository is forked from [piexifjs](https://github.com/hMatoba/piexifjs) and all praise should go to the creator of this great library.
9-
10-
```
11-
npm install piexif-ts
12-
```
5+
6+
Fix of the Typescript version of the original [piexifjs](https://github.com/hMatoba/piexifjs) as I was having trouble using it. See original documentation for how to use it.
137

148
How to Use
159
----------
1610

11+
It's very similar to the javascript library, but with some slight differences. Below is an example of how you can use this:
12+
13+
```typescript
14+
import piexif, { IExif, IExifElement, TagValues } from 'piexif-ts';
15+
16+
var file = evt.target.files[0];
17+
18+
var zeroth: IExifElement = {};
19+
var exif: IExifElement = {};
20+
var gps: IExifElement = {};
21+
zeroth[TagValues.ImageIFD.Make] = "Make";
22+
zeroth[TagValues.ImageIFD.XResolution] = [777, 1];
23+
zeroth[TagValues.ImageIFD.YResolution] = [777, 1];
24+
zeroth[TagValues.ImageIFD.Software] = "Piexifjs";
25+
exif[TagValues.ExifIFD.DateTimeOriginal] = "2010:10:10 10:10:10";
26+
exif[TagValues.ExifIFD.LensMake] = "LensMake";
27+
exif[TagValues.ExifIFD.Sharpness] = 777;
28+
exif[TagValues.ExifIFD.LensSpecification] = [[1, 1], [1, 1], [1, 1], [1, 1]];
29+
gps[TagValues.GPSIFD.GPSVersionID] = [7, 7, 7, 7];
30+
gps[TagValues.GPSIFD.GPSDateStamp] = "1999:99:99 99:99:99";
31+
var exifObj: IExif = {"0th":zeroth, "Exif":exif, "GPS":gps};
32+
var exifStr = piexif.dump(exifObj);
33+
34+
var reader = new FileReader();
35+
reader.onload = function(e) {
36+
var inserted = piexif.insert(exifStr, e.target.result);
37+
38+
var image = new Image();
39+
image.src = inserted;
40+
image.width = 200;
41+
var el = $("<div></div>").append(image);
42+
$("#resized").prepend(el);
43+
44+
};
45+
reader.readAsDataURL(file);
46+
```
47+
48+
Note also that in `tsconfig.json` the following setting needs to be set to `commonjs` for some reason. I am not sure why, so if someone could explain me, please do.
49+
50+
```json
51+
{
52+
...
53+
"compilerOptions": {
54+
"module": "commonjs",
55+
...
56+
}
57+
}
58+
```
59+
1760
[Read the Docs](https://piexifjs.readthedocs.io/en/2.0/index.html)
1861

1962
Dependency

0 commit comments

Comments
 (0)