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 5285011
Showing 1 changed file with 28 additions and 0 deletions.
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 5285011

Please sign in to comment.