Created
September 9, 2022 15:04
-
-
Save adrhill/dcc4d85c93de937842d560835a496468 to your computer and use it in GitHub Desktop.
Convert image to PPM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Images, TestImages | |
img = testimage("cameraman") | |
img = convert.(RGB{N0f8}, img) | |
open("cameraman.ppm", "w+") do io | |
println(io, "P6") | |
println(io, size(img, 2), " ", size(img, 1)) | |
println(io, 255) | |
for row in eachrow(img) | |
for px in row | |
write(io, px.r.i) | |
write(io, px.g.i) | |
write(io, px.b.i) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment