summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Pässler <milan@petabyte.dev>2021-03-13 11:49:03 +0100
committerMilan Pässler <milan@petabyte.dev>2021-03-13 11:49:03 +0100
commit234c1fc04fef5848a205a7dea96bea29ba5d4e65 (patch)
tree8e04a378bf4a787409dd1540f9ab6865c49ece09
parent5637b7d5aaccda626b7b274bfb72a69324bb4720 (diff)
downloadnimjpg-234c1fc04fef5848a205a7dea96bea29ba5d4e65.tar.gz
nimjpg-234c1fc04fef5848a205a7dea96bea29ba5d4e65.tar.bz2
nimjpg-234c1fc04fef5848a205a7dea96bea29ba5d4e65.zip
parse sof section
-rw-r--r--exif.nim1
-rw-r--r--jpg.nim14
2 files changed, 13 insertions, 2 deletions
diff --git a/exif.nim b/exif.nim
index 09bba88..8da05eb 100644
--- a/exif.nim
+++ b/exif.nim
@@ -1,4 +1,3 @@
-import asyncdispatch
import libexif
import tables
diff --git a/jpg.nim b/jpg.nim
index 81be222..dd2876f 100644
--- a/jpg.nim
+++ b/jpg.nim
@@ -86,7 +86,19 @@ proc collect_jpg*(file: AsyncFile): Future[JpgInfo] {.gcsafe,async.} =
else:
if toHex(marker).startsWith("C"):
echo "found SOF"
- file.skipSection().await
+ let section_start = file.getFilePos() + 2
+ let section_end = section_start + int64(file.getSectionSize().await)
+ var precision, components: uint8
+ var height, width: uint16
+ discard parseHex(toHex(file.read(1).await), precision)
+ echo(" precision ", precision)
+ discard parseHex(toHex(file.read(2).await), height)
+ echo(" height ", height)
+ discard parseHex(toHex(file.read(2).await), width)
+ echo(" width ", width)
+ discard parseHex(toHex(file.read(1).await), components)
+ echo(" components ", components)
+ file.setFilePos(section_end)
continue
echo("unknown section: ", toHex(marker))