fix: exiftool not working on docker

This commit is contained in:
diced 2022-12-02 17:35:47 -08:00
parent 6d2d071293
commit 738e25feda
No known key found for this signature in database
GPG key ID: 370BD1BA142842D1
2 changed files with 9 additions and 1 deletions

View file

@ -45,6 +45,7 @@ ENV PRISMA_QUERY_ENGINE_BINARY=/prisma-engines/query-engine \
PRISMA_CLIENT_ENGINE_TYPE=binary
RUN apk add --no-cache openssl openssl-dev
RUN apk add --no-cache perl procps
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1

View file

@ -1,6 +1,6 @@
import { Image } from '@prisma/client';
import { createWriteStream } from 'fs';
import { exiftool, Tags } from 'exiftool-vendored';
import { ExifTool, Tags } from 'exiftool-vendored';
import datasource from 'lib/datasource';
import Logger from 'lib/logger';
import { tmpdir } from 'os';
@ -10,6 +10,8 @@ import { readFile, unlink } from 'fs/promises';
const logger = Logger.get('exif');
export async function readMetadata(filePath: string): Promise<Tags> {
const exiftool = new ExifTool({ cleanupChildProcs: false });
const exif = await exiftool.read(filePath);
logger.debug(`exif(${filePath}) -> ${JSON.stringify(exif)}`);
@ -25,10 +27,13 @@ export async function readMetadata(filePath: string): Promise<Tags> {
delete exif.errors;
delete exif.Warning;
await exiftool.end(true);
return exif;
}
export async function removeGPSData(image: Image): Promise<void> {
const exiftool = new ExifTool({ cleanupChildProcs: false });
const file = join(tmpdir(), `zipline-exif-remove-${Date.now()}-${image.file}`);
logger.debug(`writing temp file to remove GPS data: ${file}`);
@ -82,5 +87,7 @@ export async function removeGPSData(image: Image): Promise<void> {
logger.debug(`removing temp file: ${file}`);
await unlink(file);
await exiftool.end(true);
return;
}