Skip to content

Instantly share code, notes, and snippets.

@Chandler
Created November 21, 2017 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chandler/1f4d3b6d423ed3c797595f2c734cef95 to your computer and use it in GitHub Desktop.
Save Chandler/1f4d3b6d423ed3c797595f2c734cef95 to your computer and use it in GitHub Desktop.
import numpy as np
import rasterio
original = rasterio.open("original.tif").read()
# cmd:
# convert -compress LZW -type TrueColor original.tif lossless.tif
lossless = rasterio.open("lossless.tif").read()
# cmd:
# convert original.tif -type TrueColor lossy.jpg
lossy = rasterio.open("lossy.jpg").read()
print original.shape, lossless.shape, lossy.shape
#passes yay
np.testing.assert_almost_equal(original, lossless)
# fails
np.testing.assert_almost_equal(original, lossy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment