Last active
February 19, 2016 19:33
-
-
Save satosystems/94181c14883a215cba01 to your computer and use it in GitHub Desktop.
Haskell でサムネイル #2 ref: http://qiita.com/satosystems/items/669a8b3fdfa535582cb4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ identify original.jpg | |
original.jpg JPEG 3264x2448 3264x2448+0+0 8-bit sRGB 3.288MB 0.000u 0:00.000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ identify -format "%w %h" original.jpg | |
3264 2448 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ convert -resize 200x150 original.jpg thumb.jpg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ convert -auto-orient -strip -resize 200x200 original.jpg thumb.jpg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
thumb <- mkThumbnail' ((50, 50), (200, 200)) contents | |
case thumb of | |
(Left _) -> return Nothing | |
(Right t) -> return $ Just (fst $ sz t, snd $ sz t) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
system $ "convert -auto-orient -strip -resize 200x200 " ++ org ++ " " ++ thumb | |
wh <- readProcess "identify" ["-format", "%w %h", thumb] [] | |
let a = " " `splitOn` wh | |
return $ Just (read $ a !! 0, read $ a !! 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Either (either) | |
import Data.Map.Lazy (fromList) | |
import Graphics.HsExif (getOrientation, parseFileExif) | |
file :: FilePath | |
file = "tools/4f517b31-caea-4ade-9cc5-069d6c9970dd.jpeg" | |
main :: IO () | |
main = do | |
eexif <- parseFileExif file | |
let exif = either (\a -> fromList []) id eexif | |
mio = getOrientation exif | |
print mio |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment