eagletmtの日記 このページをアンテナに追加



JPEG 判定の ByteString バージョン

15:30 | JPEG 判定の ByteString バージョン - eagletmtの日記 を含むブックマーク はてなブックマーク - JPEG 判定の ByteString バージョン - eagletmtの日記 JPEG 判定の ByteString バージョン - eagletmtの日記 のブックマークコメント


ByteString を使うならこんな感じですかね.

import Data.ByteString (ByteString, isPrefixOf, isSuffixOf, pack, hGetContents)
import System.Environment (getArgs)
import System.IO (openBinaryFile, IOMode(..), hClose)
import Control.Exception (bracket)

jpgCheck :: ByteString -> Bool
jpgCheck xs = checkSOI xs && checkEOI xs

checkSOI :: ByteString -> Bool
checkSOI = isPrefixOf magic
    magic = pack [0xFF, 0xD8]

checkEOI :: ByteString -> Bool
checkEOI = isSuffixOf magic
    magic = pack [0xFF, 0xD9]

main = do
  args <- getArgs
  if null args
    then putStrLn "Error! Usage: jpgCheck filename"
    else bracket (openBinaryFile (head args) ReadMode) hClose (\h -> hGetContents h >>= return . jpgCheck) >>= print



MiralMiral2012/07/24 11:57Clothing has always been a thing that has been given a great imantrpoce by human beings. It displays the attitude that the people exhibit. Lots of brands have been existent in the clothing industry and a famous one among them is the Ed hardy clothing brand.The brand got its name from the famous American tattoo artist Ed Hardy. He was a very famous tattoo artist and has published many books on tattooing techniques. But his tattooing turned into a brand by the efforts of a company called Christian Audiger. This company was a very famous and very powerful company in the field of clothing. They felt that it would be appropriate to create a brand called Ed hardy and use Hardy's art as the main selling point for the brand. This venture had turned out to be a very successful one and Ed hardy clothing is one of the most famous brands in the clothing industry.The brand became very famous because it was worn by many famous celebrities like Madonna, Britney spears and also Sylvester Stallone. The brand has clothes for men, women, and kids. They have also diversified their business by having a lot of accessories to support their clothing business. for men they have a variety of products such as active wear, denim, outwear, swim trucks, sweaters, t-shirts, tops etc. the accessories include things such as belts, caps, scarves, shoes, socks, jeweler, sunglasses, ties and even wallets.The art works is a unique combination of American and Japanese cultures. The unique selling proposition of the brand is the way in which the company has used the art works of Ed hardy.

vwroqwppopuvwroqwppopu2012/07/25 02:446GM90g <a href="http://tmmnjjvfxgir.com/">tmmnjjvfxgir</a>

mxevgpzmxevgpz2012/07/26 00:44Vm2BbQ , [url=http://apizuuyiarvh.com/]apizuuyiarvh[/url], [link=http://geenjzbpyzxf.com/]geenjzbpyzxf[/link], http://rvbptmoqgzjf.com/

kpmqvmbukpmqvmbu2012/07/26 19:315ev01n <a href="http://vwtuckrgsduq.com/">vwtuckrgsduq</a>

トラックバック - http://haskell.g.hatena.ne.jp/eagletmt/20090819