diff --git a/IHaskell/Display/Magic.hs b/IHaskell/Display/Magic.hs
new file mode 100644
--- /dev/null
+++ b/IHaskell/Display/Magic.hs
@@ -0,0 +1,69 @@
+{-# LANGUAGE ViewPatterns, TypeSynonymInstances, FlexibleInstances #-}
+module IHaskell.Display.Magic () where
+
+import IHaskell.Display
+import Magic
+import qualified Data.ByteString as B
+import qualified Data.ByteString.Unsafe as B
+import qualified Data.ByteString.Base64 as Base64
+import qualified Data.ByteString.Char8 as Char
+import qualified Data.ByteString.UTF8 as B
+
+import Text.Read
+import Data.Char
+
+import qualified Data.Text as T
+import qualified Data.Text.Encoding as T
+import Data.ByteString.UTF8
+
+instance IHaskellDisplay T.Text where
+    display = display . T.encodeUtf8
+
+instance IHaskellDisplay B.ByteString where
+    display x = do
+        m <- magicOpen []
+        magicLoadDefault m
+        f <- B.unsafeUseAsCStringLen x (magicCString m)
+        return $ Display [withClass (parseMagic f) x]
+
+b64 :: B.ByteString -> String
+b64 = Char.unpack . Base64.encode
+
+withClass :: MagicClass -> B.ByteString -> DisplayData
+withClass SVG = svg . B.toString
+withClass (PNG w h) = png w h . Base64.encode
+withClass JPG = jpg 400 300 . Base64.encode
+withClass HTML = html . B.toString 
+withClass LaTeX = latex . B.toString
+withClass _ = plain . B.toString
+
+{- | parse the string produced by magic.
+
+>>> parseMagic "LaTeX 2e document, ASCII text, with very long lines"
+LaTeX
+
+>>> parseMagic "PNG image data, 480 x 480, 8-bit/color RGB, non-interlaced"
+PNG 480 480
+
+>>> parseMagic "HTML document, ASCII text, with very long lines"
+HTML
+
+>>> parseMagic "JPEG image data, JFIF standard 1.01"
+JPG
+
+-}
+parseMagic :: String -> MagicClass
+parseMagic f = case words f of
+    "SVG" : _ -> SVG
+    "PNG" : _image : _data :
+        (readMaybe -> Just w) : _x :
+        (readMaybe . takeWhile isDigit -> Just h) : _ -> PNG w h
+    "LaTeX" : _ -> LaTeX
+    "HTML" : _ -> HTML
+    "JPEG" : _ -> JPG
+    _ -> Unknown
+
+
+data MagicClass =
+    SVG | PNG Int Int | JPG | HTML | LaTeX | Unknown
+    deriving Show
diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2013 Andrew Gibiansky
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/ihaskell-magic.cabal b/ihaskell-magic.cabal
new file mode 100644
--- /dev/null
+++ b/ihaskell-magic.cabal
@@ -0,0 +1,78 @@
+-- Initial ihaskell-display.cabal generated by cabal init.  For further 
+-- documentation, see http://haskell.org/cabal/users-guide/
+
+-- The name of the package.
+name:                ihaskell-magic
+
+-- The package version.  See the Haskell package versioning policy (PVP) 
+-- for standards guiding when and how versions should be incremented.
+-- http://www.haskell.org/haskellwiki/Package_versioning_policy
+-- PVP summary:      +-+------- breaking API changes
+--                   | | +----- non-breaking API additions
+--                   | | | +--- code changes with no API change
+version:             0.1.0.0
+
+-- A short (one-line) description of the package.
+synopsis:            IHaskell display instances for bytestrings
+
+-- A longer description of the package.
+-- description:         
+
+-- URL for the project homepage or repository.
+homepage:            http://www.github.com/gibiansky/IHaskell
+
+-- The license under which the package is released.
+license:             MIT
+
+-- The file containing the license text.
+license-file:        LICENSE
+
+-- The package author(s).
+author:              Adam Vogt
+
+-- An email address to which users can send suggestions, bug reports, and 
+-- patches.
+maintainer:          andrew.gibiansky@gmail.com
+
+-- A copyright notice.
+-- copyright:           
+
+category:            Development
+
+build-type:          Simple
+
+-- Extra files to be distributed with the package, such as examples or a 
+-- README.
+-- extra-source-files:  
+
+-- Constraint on the version of Cabal needed to build this package.
+cabal-version:       >=1.16
+
+
+library
+  -- Modules exported by the library.
+  exposed-modules:     IHaskell.Display.Magic
+  
+  -- Modules included in this library but not exported.
+  -- other-modules:       
+  
+  -- Language extensions.
+  default-extensions: DoAndIfThenElse
+              OverloadedStrings
+             
+  -- Other library packages from which modules are imported.
+  build-depends:       base ==4.6.*,
+                       classy-prelude >=0.6,
+                       magic >= 1.0.8,
+                       text,
+                       bytestring,
+                       utf8-string,
+                       base64-bytestring,
+                       ihaskell >= 0.3
+  
+  -- Directories containing source files.
+  -- hs-source-dirs:      
+  
+  -- Base language which the package is written in.
+  default-language:    Haskell2010
+  
