Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing ExifDateTime fails with an assertion error #50

Closed
plampila opened this issue Jun 16, 2019 · 6 comments
Closed

Writing ExifDateTime fails with an assertion error #50

plampila opened this issue Jun 16, 2019 · 6 comments

Comments

@plampila
Copy link

Describe the bug
Writing ExifDateTime fails with an assertion error.

{ AssertionError [ERR_ASSERTION]: cannot encode {"year":2019,"month":1,"day":1,"hour":0,"minute":0,"second":0}
    at enc (...\node_modules\exiftool-vendored\dist\WriteTask.js:73:36)
...

To Reproduce

const exiftool = require("exiftool-vendored").exiftool;
const ExifDateTime = require("exiftool-vendored").ExifDateTime;

test().catch(e => { console.error(e); });

async function test() {
    try {
        await exiftool.write('test.jpg', {
            CreateDate: new ExifDateTime(2019, 1, 1, 0, 0, 0),
        });
    } finally {
        await exiftool.end();
    }
}

Environment (please complete the following information):
exiftool-vendored v8.12.0
node v10.10.0
Windows 10

@mceachen
Copy link
Member

mceachen commented Jun 16, 2019

Use ExifDate if you don't have time, or just set the field to a string, formatted in EXIF (2019:01:01)

@plampila
Copy link
Author

I have set the time, but it still fails.

It fails even if I use ExifDate.

If it's intended to fail, it surely should not fail with an assertion error.

When using TypeScript it is not possible to use ExifDate or string without forcing it to ignore type check.

@mceachen mceachen reopened this Jun 16, 2019
@mceachen
Copy link
Member

When using TypeScript it is not possible to use ExifDate or string without forcing it to ignore type check.

Agreed, that should be fixed.

@mceachen
Copy link
Member

mceachen commented Jun 16, 2019

Note that CreateDate must be a datetime, not just a date:

 $ exiftool -CreateDate=2019:01:01 test.jpg
Warning: Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z]) in ExifIFD:CreateDate (PrintConvInv)

There are tags that allow for just dates, like ReleaseDate. I'll make sure that compiles and round-trips write/reads.

@mceachen
Copy link
Member

Better write tag support was implemented in the newest release.

@plampila
Copy link
Author

Works like a charm now, much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants