forked from rkalla/exiftool
-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Since we need to handle real-time image streams, converting the stream to a file for processing with exiftool and then converting it back to a stream introduces significant IO overhead, which is inefficient and wasteful.
String tempFileNamePrefix = "exiftool-input-" + UUID.randomUUID().toString();
File tempInputFile = File.createTempFile(tempFileNamePrefix, extension);
try {
try (FileOutputStream tempInputFileStream = new FileOutputStream(tempInputFile)) {
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
tempInputFileStream.write(buffer, 0, bytesRead);
}
}
exifTool.setImageMeta(tempInputFile, metadata);
try (FileInputStream tempInputFileStream = new FileInputStream(tempInputFile)) {
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = tempInputFileStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
}
} finally {
tempInputFile.delete();
}
Metadata
Metadata
Assignees
Labels
No labels