File: Undefined9.hs

package info (click to toggle)
haskell-ghc-exactprint 1.7.1.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,044 kB
  • sloc: haskell: 32,076; makefile: 7
file content (30 lines) | stat: -rw-r--r-- 584 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{-# LANGUAGE QuasiQuotes, TypeFamilies #-}

module Image.PNG (isPNG, pngSize) where

import Data.Maybe
import File.Binary.PNG
import File.Binary
import File.Binary.Instances
import File.Binary.Instances.BigEndian

isPNG :: String -> Bool
isPNG img = isJust (fromBinary () img :: Maybe (PNGHeader, String))

pngSize :: String -> Maybe (Double, Double)
pngSize src = case getChunks src of
    Right cs -> Just
        (fromIntegral $ width $ ihdr cs, fromIntegral $ height $ ihdr cs)
    _ -> Nothing

[binary|

PNGHeader deriving Show

1: 0x89
3: "PNG"
2: "\r\n"
1: "\SUB"
1: "\n"

|]