Skip to content

Commit

Permalink
Add other missing data types.
Browse files Browse the repository at this point in the history
  • Loading branch information
Imbruced committed Sep 24, 2024
1 parent 8735051 commit f03527d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ object GeoPackageConnectionManager {
srsID = srsID,
zoomLevelMetadata = getZoomLevelData,
tileRowMetadata = null)
}
finally {
} finally {
rs.close()
closeStatement(statement)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ import javax.imageio.ImageIO

object Image {

private val WEBP_HEX = "52494646"
private val PNG_HEX = "89504E470D0A1A0A"
private val TIFF_HEX = Seq("49492A00", "4D4D002A")
private val JPEG_HEX = Seq("FFD8FFE0", "FFD8FFE1", "FFD8FFE8")

def readImageFile(
byteArray: Array[Byte],
tileMetadata: TileMetadata,
Expand All @@ -55,23 +60,23 @@ object Image {
val magicBytes = byteArray.take(12)
val magicHex = bytesToHex(magicBytes)

if (magicHex.startsWith("524946")) {
if (magicHex.startsWith(WEBP_HEX)) {
val webpCheck = new String(byteArray.slice(8, 12))
if (webpCheck == "WEBP") {
return ImageFileFormat.WEBP
}
}

if (magicHex.startsWith("89504E470D0A1A0A")) {
if (magicHex.startsWith(PNG_HEX)) {
return ImageFileFormat.PNG
}

if (magicHex.startsWith("FFD8FFE0") || magicHex.startsWith("FFD8FFE1") || magicHex.startsWith(
"FFD8FFE8")) {
if (JPEG_HEX.exists(magicHex.startsWith)) {
return ImageFileFormat.JPEG
}

if (magicHex.startsWith("49492A00") || magicHex.startsWith("4D4D002A")) {

if (TIFF_HEX.exists(magicHex.startsWith)) {
return ImageFileFormat.TIFF
}

Expand Down

0 comments on commit f03527d

Please sign in to comment.