JuicyPixelsで画像をオイタしてみた
JuicyPixelsとは、png、jpg、gif、などの画像を色々いたずらできるhaskellのパッケージで、お勉強をかねて画像をいたずらしてみました、でついでにgentooのebuildも作って見ましたので良かったら使って下さいJuicyPixelsのインストール
laymanリポジトリにebuildを作っておいたのでそちらをもってきて、maskを外してください。iichiko ~ # layman -a karky7
...
...
iichiko ~ # emerge -s juicypixels
Searching...
[ Results for search key : juicypixels ]
[ Applications found : 1 ]
* dev-haskell/juicypixels [ Masked ]
Latest version available: 3.0
Latest version installed: [ Not Installed ]
Size of files: 58 kB
Homepage: https://github.com/Twinside/Juicy.Pixels
Description: This library can load and store images in PNG,Bitmap, Jpeg, Radiance and read Gif images.
License: BSD3
...
iichiko ~ # emerge -pv juicypixels
* Last emerge --sync was 33d 4h 29m 37s ago.
These are the packages that would be merged, in order:
Calculating dependencies... done!
[ebuild U ~] dev-haskell/primitive-0.5.0.1:0/0.5.0.1::gentoo-haskell [0.4.1:0/0::gentoo-haskell] USE="doc hoogle -hscolour -profile" 11 kB
[ebuild U ~] dev-haskell/vector-0.10.0.1:0/0.10.0.1::gentoo-haskell [0.9.1:0/0::gentoo-haskell] USE="doc hoogle -hscolour -profile" 101 kB
[ebuild N ~] dev-haskell/juicypixels-3.0:0/3.0::karky7 USE="doc -hscolour -profile" 59 kB
Total: 3 packages (2 upgrades, 1 new), Size of downloads: 170 kB
* IMPORTANT: 10 news items need reading for repository 'gentoo'.
* Use eselect news to read news items.
iichiko ~ # emerge dev-haskell/juicypixels
binaryパッケージが最新過ぎるとバージョンの依存関係でエラーになるので、その時はbinary-0.6.*あたりをインストールしてみて下さい。
AKIRAの金田をpngからjpgにしてみる
png画像をjpg画像へそのまま変換してファイルに保存するサンプルコード、初めに適当なpngファイルを用意して下さい。
「大覚 アキラ様」の金田.pngをjpgに変換する
import Codec.Picture
img :: IO (Either String DynamicImage)
img = readImage "akira.png"
main :: IO()
main = do
img >>= (\(Right dynamicImage) -> return dynamicImage) >>=
(\dynamicImage -> saveJpgImage 100 "akira.jpg" dynamicImage)
同一ディレクトリにjpgが保存される、まぁ同じ画像でおもろくないが...でもhaskellたのしい、では

0 件のコメント:
コメントを投稿