Skip to content

Commit

Permalink
Added support for WebP (#400)
Browse files Browse the repository at this point in the history
Added support for WebP

Also:

* Moved QOI to Image formats section.
* Changed AVI and WAV detectors (`detectavi`, and `detectwav`) to also use `detect_riff`.
* Updated version to 1.16.5
  • Loading branch information
stemann authored Nov 13, 2024
1 parent bf42b4f commit 50ea61f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "FileIO"
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
version = "1.16.4"
version = "1.16.5"

[deps]
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Expand Down
49 changes: 28 additions & 21 deletions src/registry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ const idLibSndFile = :LibSndFile => UUID("b13ce0c6-77b0-50c6-a2db-140568b8d1a5")
const idJpegTurbo = :JpegTurbo => UUID("b835a17e-a41a-41e7-81f0-2f016b05efe0")
const idNPZ = :NPZ => UUID("15e1cf62-19b3-5cfa-8e77-841668bca605")

# Cf. https://developers.google.com/speed/webp/docs/riff_container#riff_file_format, and https://learn.microsoft.com/en-us/windows/win32/xaudio2/resource-interchange-file-format--riff-#chunks
function detect_riff(io::IO, expected_magic::AbstractVector{UInt8})
getlength(io) >= 12 || return false
buf = Vector{UInt8}(undef, 4)
fourcc = read!(io, buf)
fourcc == b"RIFF" || return false
seek(io, 8)
magic = read!(io, buf)
return magic == expected_magic
end

### Simple cases

# data formats
Expand Down Expand Up @@ -204,6 +215,13 @@ add_format(
".pcx",
[idImageMagick]
)
add_format(
format"QOI",
"qoif",
".qoi",
[:QOI => UUID("4b34888f-f399-49d4-9bb3-47ed5cae4e65")],
[idImageIO]
)
add_format(
format"SVG",
(),
Expand All @@ -218,19 +236,18 @@ add_format(
[idImageIO],
[idImageMagick]
)
detect_webp(io) = detect_riff(io, b"WEBP")
add_format(
format"WebP",
detect_webp,
".webp",
[:WebP => UUID("e3aaa7dc-3e4b-44e0-be63-ffb868ccd7c1")],
[idImageIO]
)

# Video formats

# AVI is a subtype of RIFF, as is WAV
function detectavi(io)
getlength(io) >= 12 || return false
magic = read!(io, Vector{UInt8}(undef, 4))
magic == b"RIFF" || return false
seek(io, 8)
submagic = read!(io, Vector{UInt8}(undef, 4))

submagic == b"AVI "
end
detectavi(io) = detect_riff(io, b"AVI ")
add_format(format"AVI", detectavi, ".avi", [idImageMagick], [idVideoIO])

"""
Expand Down Expand Up @@ -278,15 +295,7 @@ add_format(format"OUT", "# Bundle file v0.3\n", ".out", [:BundlerIO => UUID("654
add_format(format"GSLIB", (), [".gslib",".sgems"], [:GslibIO => UUID("4610876b-9b01-57c8-9ad9-06315f1a66a5")])

### Audio formats
function detectwav(io)
getlength(io) >= 12 || return false
buf = Vector{UInt8}(undef, 4)
read!(io, buf)
buf == b"RIFF" || return false
seek(io, 8)
read!(io, buf)
buf == b"WAVE"
end
detectwav(io) = detect_riff(io, b"WAVE")
add_format(format"WAV", detectwav, ".wav", [:WAV => UUID("8149f6b0-98f6-5db9-b78f-408fbbb8ef88")], [idLibSndFile])
add_format(format"FLAC", "fLaC", ".flac", [:FLAC => UUID("abae9e3b-a9a0-4778-b5c6-ca109b507d99")], [idLibSndFile])

Expand Down Expand Up @@ -542,8 +551,6 @@ add_format(format"HTML", (), [".html", ".htm"], [MimeWriter, SAVE])

add_format(format"MIDI", "MThd", [".mid", ".midi", ".MID"], [:MIDI => UUID("f57c4921-e30c-5f49-b073-3f2f2ada663e")])

add_format(format"QOI", "qoif", ".qoi", [:QOI => UUID("4b34888f-f399-49d4-9bb3-47ed5cae4e65")], [idImageIO])

# Bibliography files.
add_format(format"BIB", (), [".bib"], [:Bibliography => UUID("f1be7e48-bf82-45af-a471-ae754a193061")])

Expand Down

2 comments on commit 50ea61f

@stemann
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/119305

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.16.5 -m "<description of version>" 50ea61f34eb30cdb1bb76caeb79251e5ce90e154
git push origin v1.16.5

Please sign in to comment.