Skip to content

Commit 90d733b

Browse files
committed
Fix the processing of extracted EXIF data
See https://www.woltlab.com/community/thread/314222/
1 parent 7a9e278 commit 90d733b

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

ts/WoltLabSuite/Core/Component/File/Upload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ export function setup(): void {
399399
const result = checksums[i];
400400

401401
if (result.status === "fulfilled") {
402-
const exif = exifData.get(validFiles[i]) || null;
402+
const exif = exifData.get(validFiles[i]) || exifData.get(files[i]) || null;
403403
void upload(element, validFiles[i], result.value, exif);
404404
} else {
405405
throw new Error(result.reason);

wcfsetup/install/files/js/WoltLabSuite/Core/Component/File/Upload.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wcfsetup/install/files/lib/data/file/FileEditor.class.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,20 @@ public static function createFromTemporary(FileTemporary $fileTemporary): File
7777
$fileSize = $fileTemporary->fileSize;
7878
$fileHash = $fileTemporary->fileHash;
7979
if ($isImage) {
80+
$exifData = $fileTemporary->exifData;
81+
if ($exifData !== null) {
82+
$exifData = JSON::decode($exifData);
83+
}
84+
8085
$imageWasModified = false;
8186
try {
82-
$imageWasModified = self::normalizeImageRotation($pathname, $width, $height, $mimeType);
87+
$imageWasModified = self::normalizeImageRotation(
88+
$pathname,
89+
$width,
90+
$height,
91+
$mimeType,
92+
$exifData,
93+
);
8394
} catch (\Throwable) {
8495
}
8596

@@ -176,7 +187,13 @@ public static function createFromExistingFile(
176187

177188
$imageWasModified = false;
178189
try {
179-
$imageWasModified = self::normalizeImageRotation($pathname, $width, $height, $mimeType);
190+
$imageWasModified = self::normalizeImageRotation(
191+
$pathname,
192+
$width,
193+
$height,
194+
$mimeType,
195+
$exifData,
196+
);
180197
} catch (\Throwable) {
181198
}
182199

@@ -221,20 +238,22 @@ public static function createFromExistingFile(
221238
* Rotating the image can cause the dimensions to change, the image size to
222239
* differ and the file hash to be different.
223240
*
241+
* @param null|array<string, array<string, mixed>> $exifData
224242
* @return bool true if the image was modified.
225243
*/
226244
private static function normalizeImageRotation(
227245
string $pathname,
228246
int $width,
229247
int $height,
230-
string $mimeType
248+
string $mimeType,
249+
?array $exifData,
231250
): bool {
232251
$adapter = ImageHandler::getInstance()->getAdapter();
233252
if (!$adapter->checkMemoryLimit($width, $height, $mimeType)) {
234253
return false;
235254
}
236255

237-
$exifData = ExifUtil::getExifData($pathname);
256+
$exifData ??= ExifUtil::getExifData($pathname);
238257
if ($exifData === []) {
239258
return false;
240259
}

0 commit comments

Comments
 (0)