Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ViralBShah authored Feb 27, 2024
2 parents 626fc1f + d30fbd7 commit 2bd425f
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 16 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
2 changes: 1 addition & 1 deletion .github/workflows/Documenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: nightly # change this to 1.6 once's that's official
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/Invalidations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Invalidations

on:
pull_request:

concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: always.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
evaluate:
# Only run on PRs to the default branch.
# In the PR trigger above branches can be specified only explicitly whereas this check should work for master, main, or any other default branch
if: github.base_ref == github.event.repository.default_branch
runs-on: ubuntu-latest
steps:
- uses: julia-actions/setup-julia@v1
with:
version: '1'
- uses: actions/checkout@v4
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-invalidations@v1
id: invs_pr

- uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-invalidations@v1
id: invs_default

- name: Report invalidation counts
run: |
echo "Invalidations on default branch: ${{ steps.invs_default.outputs.total }} (${{ steps.invs_default.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY
echo "This branch: ${{ steps.invs_pr.outputs.total }} (${{ steps.invs_pr.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY
- name: Check if the PR does increase number of invalidations
if: steps.invs_pr.outputs.total > steps.invs_default.outputs.total
run: exit 1
27 changes: 21 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,26 @@ jobs:
strategy:
fail-fast: false
matrix:
julia-version: ['1.0', '1', 'nightly']
julia-arch: [x64, x86]
os: [ubuntu-latest, macOS-latest, windows-latest]
julia-version: ['1.0', '1.6', '1', 'nightly']
julia-arch: [x64, x86, aarch64]
os: [ubuntu-latest, windows-latest, macOS-13, macOS-14]
exclude:
- os: macOS-latest
- os: ubuntu-latest
julia-arch: aarch64
- os: windows-latest
julia-arch: aarch64
- os: macOS-13
julia-arch: x86
- os: macOS-13
julia-arch: aarch64
- os: macOS-14
julia-arch: x86
- os: macOS-14
julia-arch: x64
- os: macOS-14
julia-version: '1.6'
- os: macOS-14
julia-version: '1.0'

steps:
- name: Set git to use LF (Windows only)
Expand All @@ -31,14 +45,15 @@ jobs:
run: |
echo "TMP=${USERPROFILE}\AppData\Local\Temp" >> ${GITHUB_ENV}
echo "TEMP=${USERPROFILE}\AppData\Local\Temp" >> ${GITHUB_ENV}
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.julia-version }}
- uses: julia-actions/julia-runtest@latest
env:
JULIA_NUM_THREADS: 2
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v4
with:
file: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
15 changes: 13 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
name = "FileIO"
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
version = "1.16.0"
version = "1.16.2"

[deps]
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
Pkg = "<0.0.1, 0.7, 1"
Requires = "1"
UUIDs = "<0.0.1, 0.7, 1"
julia = "0.7, 1"
Aqua = "0.8"
CSVFiles = "1"
CodecZlib = "0.5, 0.6, 0.7"
ColorTypes = "0.11"
FilePathsBase = "0.9"
HTTP = "0.6, 1"
Random = "<0.0.1, 0.7, 1"
Test = "<0.0.1, 0.7, 1"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
CSVFiles = "5d742f6a-9f54-50ce-8119-2520741973ca"
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
Expand All @@ -21,4 +32,4 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["ColorTypes", "CodecZlib", "CSVFiles", "FilePathsBase", "HTTP", "Random", "Test"]
test = ["Aqua", "ColorTypes", "CodecZlib", "CSVFiles", "FilePathsBase", "HTTP", "Random", "Test"]
8 changes: 7 additions & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Install FileIO within Julia via
```julia
julia> using Pkg

julia> Pkg.add("FileIO")`
julia> Pkg.add("FileIO")
```

## Usage
Expand Down Expand Up @@ -48,6 +48,12 @@ Likewise, saving might be as simple as
save(filename, obj)
```

You can also utilize a piping style to save values to files like this

```julia
obj |> save(filename)
```

If you just want to inspect a file to determine its format, then

```julia
Expand Down
8 changes: 6 additions & 2 deletions src/mimesave.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ module MimeWriter

using ..FileIO: File, @format_str

function save(file::File{format"PNG"}, data)
function save(file::File{format"PNG"}, data; ppi::Union{Nothing,Number}=nothing)
if showable("image/png", data)
open(file.filename, "w") do s
show(IOContext(s, :full_fidelity=>true), "image/png", data)
if ppi === nothing
show(IOContext(s, :full_fidelity=>true), "image/png", data)
else
show(IOContext(s, :full_fidelity=>true, :ppi=>ppi), "image/png", data)
end
end
else
throw(ArgumentError("Argument does not support conversion to png."))
Expand Down
13 changes: 9 additions & 4 deletions src/registry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const idImageIO = :ImageIO => UUID("82e4d734-157c-48bb-816b-45c225c6df19")
const idImageMagick = :ImageMagick => UUID("6218d12a-5da1-5696-b52f-db25d2ecc6d1")
const idMeshIO = :MeshIO => UUID("7269a6da-0436-5bbc-96c2-40638cbb6118")
const idNetpbm = :Netpbm => UUID("f09324ee-3d7c-5217-9330-fc30815ba969")
const idOpenCV = :OpenCV => UUID("f878e3a2-a245-4720-8660-60795d644f2a")
const idQuartzImageIO = :QuartzImageIO => UUID("dca85d43-d64c-5e67-8c65-017450d5d020")
const idRData = :RData => UUID("df47a6cb-8c03-5eed-afd8-b6050d6c41da")
const idStatFiles = :StatFiles => UUID("1463e38c-9381-5320-bcd4-4134955f093a")
Expand Down Expand Up @@ -116,6 +117,7 @@ add_format(format"AVSfld", "# AVS", [".fld"], [idAVSfldIO])
add_format(format"CSV", (), [".csv"], [idCSVFiles])
add_format(format"TSV", (), [".tsv"], [idCSVFiles])
add_format(format"Feather", "FEA1", [".feather"], [:FeatherFiles => UUID("b675d258-116a-5741-b937-b79f054b0542")])
add_format(format"Arrow", b"ARROW1\0\0", [".arrow"], [:Arrow => UUID("69666777-d1a9-59fb-9406-91d4454c9d45")])
add_format(format"Excel", (), [".xls", ".xlsx"], [:ExcelFiles => UUID("89b67f3b-d1aa-5f6f-9ca4-282e8d98620d")])
add_format(format"Stata", (), [".dta"], [idStatFiles, LOAD])
add_format(format"SPSS", "\$FL2", [".sav"], [idStatFiles, LOAD])
Expand Down Expand Up @@ -148,7 +150,7 @@ add_format(format"EXR", UInt8[0x76,0x2f,0x31,0x01], ".exr",
add_format(format"HDR", UInt8[0x23,0x3f,0x52,0x41,0x44,0x49,0x41,0x4e], ".hdr", [idImageMagick])
add_format(format"ICO", UInt8[0x00,0x00,0x01,0x00], ".ico", [idImageMagick])
add_format(format"INFO", UInt8[0x7a,0x62,0x65,0x78], ".info",[idImageMagick])
add_format(format"JP2", UInt8[0x00,0x00,0x00,0x0c,0x6a,0x50,0x20,0x20], ".jp2", [idImageMagick])
add_format(format"JP2", UInt8[0x00,0x00,0x00,0x0c,0x6a,0x50,0x20,0x20], ".jp2", [idImageMagick], [idOpenCV])
add_format(format"PDB", UInt8[0x73,0x7a,0x65,0x7a], ".pdb", [idImageMagick])
add_format(format"PDF", UInt8[0x25,0x50,0x44,0x46], ".pdf", [idImageMagick], [MimeWriter, SAVE])
add_format(format"PGM", UInt8[0x50,0x35,0x0a], ".pgm", [idImageMagick])
Expand Down Expand Up @@ -179,6 +181,7 @@ add_format(
[idImageIO],
[idQuartzImageIO, OSX],
[idImageMagick],
[idOpenCV],
[MimeWriter, SAVE]
)
add_format(
Expand All @@ -188,14 +191,16 @@ add_format(
[idJpegTurbo],
[idImageIO],
[idQuartzImageIO, OSX],
[idImageMagick]
[idImageMagick],
[idOpenCV]
) # 0xe1
add_format(
format"BMP",
UInt8[0x42,0x4d],
".bmp",
[idQuartzImageIO, OSX],
[idImageMagick]
[idImageMagick],
[idOpenCV]
)
add_format(
format"PCX",
Expand Down Expand Up @@ -384,7 +389,7 @@ function detecttiff(io)
end
# normal TIFF
detect_noometiff(io) = detecttiff(io) && ((:name propertynames(io)) || !(endswith(io.name, ".ome.tif>") || endswith(io.name, ".ome.tiff>")))
add_format(format"TIFF", detect_noometiff, [".tiff", ".tif"], [idImageIO], [idQuartzImageIO, OSX], [idImageMagick])
add_format(format"TIFF", detect_noometiff, [".tiff", ".tif"], [idImageIO], [idQuartzImageIO, OSX], [idImageMagick], [idOpenCV])
# OME-TIFF
detect_ometiff(io) = detecttiff(io) && (:name propertynames(io)) && (endswith(io.name, ".ome.tif>") || endswith(io.name, ".ome.tiff>"))
add_format(format"OMETIFF", detect_ometiff, [".tif", ".tiff"], [:OMETIFF => UUID("2d0ec36b-e807-5756-994b-45af29551fcf")])
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ end
include("test_mimesave.jl")
include("integration.jl")
end

using Aqua
Aqua.test_all(FileIO)

0 comments on commit 2bd425f

Please sign in to comment.