
Hi,
Here is a solution using JuicyPixels:
import Codec.Picture
import Codec.Picture.Types
main :: IO ()
main = do
Right img <- readImage "test.png"
_ <- writeDynamicPng "test2.png" (dynamicPixelMap circleImage img)
return ()
circleImage :: Pixel a => Image a -> Image a
circleImage img = generateImage (\x y -> f x y $ pixelAt img x y) edge edge
where
edge = min (imageWidth img) (imageHeight img)
f x y a = if x'*x' + y'*y' < e'*e'
then a
else colorMap (const 0) a
where
e' = edge `div` 2
x' = x - e'
y' = y - e'
Sylvain
2015-06-03 9:19 GMT+02:00 Geraldus
Hi cafe!
I want to do some trivial masking manipulation on PNG images: take a picture, crop it to square shape and then make a circular mask, i.e. take all pixels that lies outside circle with radius equal to half of image width and placed at image center and replace that pixels with zero opacity once (hope this description is clear enough).
I've found two packages for image processing so far: `friday` [1] and `unm-hip` [2], but can't figure out which of them suits my needs, maybe there are some other packages I miss?
[1] https://hackage.haskell.org/package/friday [2] https://hackage.haskell.org/package/unm-hip
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe