diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 9c352fb..c62ab1d 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -31,7 +31,7 @@ kotlin { val wasmJsMain by getting commonMain.dependencies { - api("com.ashampoo:kim:0.9.3") + api("com.ashampoo:kim:0.10") } commonTest.dependencies { diff --git a/app/src/commonMain/kotlin/HtmlGenerator.kt b/app/src/commonMain/kotlin/HtmlGenerator.kt index 422aaf9..f84b45d 100644 --- a/app/src/commonMain/kotlin/HtmlGenerator.kt +++ b/app/src/commonMain/kotlin/HtmlGenerator.kt @@ -24,7 +24,8 @@ import com.ashampoo.kim.common.toUInt8 import com.ashampoo.kim.format.ImageMetadata import com.ashampoo.kim.format.bmff.BoxReader import com.ashampoo.kim.format.bmff.BoxType -import com.ashampoo.kim.format.bmff.boxes.MetaBox +import com.ashampoo.kim.format.bmff.box.ExifBox +import com.ashampoo.kim.format.bmff.box.MetaBox import com.ashampoo.kim.format.jpeg.JpegConstants import com.ashampoo.kim.format.jpeg.JpegSegmentAnalyzer import com.ashampoo.kim.format.png.PngChunkType @@ -32,7 +33,7 @@ import com.ashampoo.kim.format.png.PngConstants import com.ashampoo.kim.format.png.PngImageParser import com.ashampoo.kim.format.tiff.TiffDirectory import com.ashampoo.kim.format.tiff.TiffReader -import com.ashampoo.kim.format.tiff.constants.TiffConstants +import com.ashampoo.kim.format.tiff.constant.TiffConstants import com.ashampoo.kim.input.ByteArrayByteReader import com.ashampoo.kim.model.ImageFormat @@ -168,10 +169,19 @@ fun generateHexHtml(bytes: ByteArray): String { val format = ImageFormat.detect(bytes) ?: return "Image format was not recognized." return when (format) { - ImageFormat.JPEG -> generateHtmlFromSlices(bytes, createJpegSlices(bytes)) - ImageFormat.TIFF -> generateHtmlFromSlices(bytes, createTiffSlices(bytes, exifBytes = false)) - ImageFormat.PNG -> generateHtmlFromSlices(bytes, createPngSlices(bytes)) - ImageFormat.HEIC -> generateHtmlFromSlices(bytes, createBaseMediaFileFormatSlices(bytes)) + + ImageFormat.JPEG -> + generateHtmlFromSlices(bytes, createJpegSlices(bytes)) + + ImageFormat.TIFF -> + generateHtmlFromSlices(bytes, createTiffSlices(bytes, exifBytes = false)) + + ImageFormat.PNG -> + generateHtmlFromSlices(bytes, createPngSlices(bytes)) + + ImageFormat.HEIC, ImageFormat.AVIF, ImageFormat.JXL -> + generateHtmlFromSlices(bytes, createBaseMediaFileFormatSlices(bytes)) + else -> "HEX view for $format is not (yet) supported." } } @@ -526,7 +536,7 @@ private fun createBaseMediaFileFormatSlices(bytes: ByteArray): List 0) + SeparatorLineType.BOLD + else + SeparatorLineType.NONE, + snipAfterLineCount = 3 + ) + ) + + slices.addAll( + createTiffSlices( + bytes = box.exifBytes, + startPosition = box.offset.toInt() + 8, + endPosition = box.offset.toInt() + box.length.toInt(), + exifBytes = true + ) + ) + } else { - val boxRange = box.offset.toInt() until box.offset.toInt() + box.length.toInt() + val boxRange = box.offset.toInt() until box.offset.toInt() + box.length.toInt() slices.add( LabeledSlice( @@ -650,9 +685,6 @@ private fun createBaseMediaFileFormatSlices(bytes: ByteArray): List +00000000 | 00 00 00 0C 4A 58 4C 20  0D 0A 87 0A             | ....JXL ....     | Box JXL  [12 bytes]
+
+00000012 | 00 00 00 14 66 74 79 70  6A 78 6C 20 00 00 00 00 | ....ftypjxl .... | Box ftyp [20 bytes]
+00000028 | 6A 78 6C 20                                      | jxl              | 
+
+00000032 | 00 00 02 4C 6A 78 6C 70  00 00 00 00 FF 0A BA 34 | ...Ljxlp.......4 | Box jxlp [588 bytes]
+00000048 | 05 21 9C 6D 0D 28 25 00  21 08 A0 20 A2 02 21 0A | .!.m.(%.!.. ..!. | 
+00000064 | 84 09 98 06 26 81 A9 00  34 74 A4 43 72 96 F8 79 | ....&...4t.Cr..y | 
+00000079 |            [ ... snip 524 bytes ... ]            |                  |
+00000604 | 4C 1F 19 CB 4A 69 01 E0  0B BD 1A 0A 3B 9A FB 01 | L...Ji......;... | 
+
+00000620 | 00 00 2D 5D 6A 62 72 64  C2 56 0C DD 6D 03 08 82 | ..-]jbrd.V..m... | Box jbrd [11613 bytes]
+00000636 | 20 B4 4C 98 2F 18 B5 84  C5 60 D7 19 1C 00 42 5D |  .L./....`....B] | 
+00000652 | 80 00 01 0A 84 5C 25 00  00 20 40 8E CA 16 8C FF | .....\%.. @..... | 
+00000667 |           [ ... snip 11549 bytes ... ]           |                  |
+00012217 | 31 D9 A2 A2 51 5F 03 30  65 6C DD AD ED 7E BF 05 | 1...Q_.0el...~.. | 
+
+00012233 | 00 00 2F 9C 45 78 69 66  00 00 00 00 49 49 2A 00 | ../.Exif....II*. | Box Exif [12188 bytes]
+00012249 | 08 00 00 00 08 00 0F 01  02 00 05 00 00 00 6E 00 | ..............n. | 
+00012265 | 00 00 10 01 02 00 0A 00  00 00 74 00 00 00 1A 01 | ..........t..... | 
+00012280 |           [ ... snip 12124 bytes ... ]           |                  |
+00024405 | E9 F1 01 00 15 15 07 7C  81 0C E2 5F FF D1 FF D9 | .......|..._.... | 
+
+00024421 | 00 00 33 97 78 6D 6C 20  3C 3F 78 70 61 63 6B 65 | ..3.xml <?xpacke | Box xml  [13207 bytes]
+00024437 | 74 20 62 65 67 69 6E 3D  27 EF BB BF 27 20 69 64 | t begin='...' id | 
+00024453 | 3D 27 57 35 4D 30 4D 70  43 65 68 69 48 7A 72 65 | ='W5M0MpCehiHzre | 
+00024468 |           [ ... snip 13143 bytes ... ]           |                  |
+00037612 | 70 61 63 6B 65 74 20 65  6E 64 3D 27 77 27 3F 3E | packet end='w'?> | 
+
+00037628 | 00 0D 42 AD 6A 78 6C 70  80 00 00 01 E0 5B 00 10 | ..B.jxlp.....[.. | Box jxlp [869037 bytes]
+00037644 | 00 98 2B 8E 50 A0 A2 1B  10 A9 94 60 10 6C 90 B0 | ..+.P......`.l.. | 
+00037660 | 50 E4 D0 37 11 5F 52 D3  54 85 1A EF 58 6D 16 90 | P..7._R.T...Xm.. | 
+00037675 |          [ ... snip 868973 bytes ... ]           |                  |
+00906649 | 92 A1 73 25 99 A2 E2 1D  A9 D6 F9 E9 CA 27 35 01 | ..s%.........'5. | 
+ diff --git a/app/src/wasmJsMain/kotlin/Main.kt b/app/src/wasmJsMain/kotlin/Main.kt index 0e61cb6..33c3965 100644 --- a/app/src/wasmJsMain/kotlin/Main.kt +++ b/app/src/wasmJsMain/kotlin/Main.kt @@ -18,7 +18,7 @@ */ import com.ashampoo.kim.Kim -import com.ashampoo.kim.format.tiff.constants.TiffTag +import com.ashampoo.kim.format.tiff.constant.TiffTag import com.ashampoo.kim.model.TiffOrientation import kotlinx.browser.document import org.khronos.webgl.ArrayBuffer diff --git a/app/src/wasmJsMain/resources/index.html b/app/src/wasmJsMain/resources/index.html index a49f0f1..b047d6b 100644 --- a/app/src/wasmJsMain/resources/index.html +++ b/app/src/wasmJsMain/resources/index.html @@ -136,13 +136,18 @@

EXIF Viewer

+ +

Drag & drop your file here
or click to select a file!

-

JPG, PNG, TIFF & HEIC files are supported.
- Processing happens solely in your browser, no servers involved.

+

Processing happens solely in your browser.

+
+ +
+ Supported formats: JPG, PNG, TIFF, HEIC, AVIF & JXL.