Skip to content

Commit

Permalink
add network load demo
Browse files Browse the repository at this point in the history
closes #103

Co-Authored-By: Santiago Pelufo <[email protected]>
  • Loading branch information
tlnagy and spelufo committed Sep 21, 2023
1 parent 55b3d72 commit 4f23041
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.9.3"
manifest_format = "2.0"
project_hash = "c44c556ada2f2ee24445dc125044717dd2f9c101"
project_hash = "6fec704fa54ba4c98a046da95a378f7e25881ee4"

[[deps.ANSIColoredPrinters]]
git-tree-sha1 = "574baf8110975760d391c710b6341da1afa48d8c"
Expand Down
2 changes: 2 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
DemoCards = "311a05b2-6137-4a5a-b473-18580a3d38b5"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
Expand Down
28 changes: 28 additions & 0 deletions docs/demos/common/network.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# ---
# title: Loading a remote TIFF
# description: This demo shows how to load a TIFF over the network
# author: Santiago Pelufo, Tamas Nagy
# cover: assets/coffee.png
# ---

# The following code can be used to load remote TIFFs without saving them to the
# disk.

using TiffImages, Downloads, FileIO

function load_tiff_without_saving(url)
buffer = IOBuffer()
Downloads.download(url, buffer)
bufstream = TiffImages.getstream(format"TIFF", buffer)
TiffImages.load(read(bufstream, TiffFile))
end

# We'll load an example from
# [`tlnagy/exampletiffs`](https://github.com/tlnagy/exampletiffs)

coffeepath = "https://github.com/tlnagy/exampletiffs/raw/11516d288c4b03a258aa3027705b0e9d2ce2b5de/coffee.tif"
coffeeimg = load_tiff_without_saving(coffeepath)

# No disks involved!

save("assets/coffee.png", coffeeimg) #src

0 comments on commit 4f23041

Please sign in to comment.