Skip to content

Commit

Permalink
Merge pull request JuliaLang#2432 from rsrock/master
Browse files Browse the repository at this point in the history
Fixes to imwrite and imshow
  • Loading branch information
timholy committed Mar 1, 2013
2 parents 396e6c4 + c1595f4 commit 4df10ac
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions extras/image.jl
Original file line number Diff line number Diff line change
Expand Up @@ -505,22 +505,31 @@ function imwrite(I, file::String)
end
h, w = size(I)
cmd = `convert -size $(w)x$(h) -depth 8 rgb: $file`
stream = fdio(writesto(cmd).fd, true)
stream, _ = writesto(cmd)
spawn(cmd)
write_bitmap_data(stream, I)
close(stream)
wait(cmd)
#wait(cmd) # currently missing?
end

function imshow(img, range)
if ndims(img) == 2
# only makes sense for gray scale images
img = imadjustintensity(img, range)
end
tmp::String = "./tmp.ppm"
imwrite(img, tmp)
cmd = `feh $tmp`
spawn(cmd)
imgout_path, imgout = mktemp()
close(imgout) # just want the path
imgout_path = imgout_path * ".tiff"
imwrite(img, imgout_path)
@osx_only spawn(`open $imgout_path`)
@linux_only begin
for checkcmd in (:feh, :gwenview)
if success(`which $checkcmd` > SpawnNullStream())
spawn(`$checkcmd $imgout_path`)
break
end
end
end
end

imshow(img) = imshow(img, [])
Expand Down

0 comments on commit 4df10ac

Please sign in to comment.