<div dir="ltr">Thank you everybody!<div><b>JuicyPixels</b> was the first package I have thought about, but I've mistaken about its functionality and didn't mentioned it here.</div><div><br></div><div><b>Sylvain</b>, thank you a lot! You've made my day!<span style="font-size:13.1999998092651px;line-height:1.5"> </span></div></div><br><div class="gmail_quote"><div dir="ltr">ср, 3 июня 2015 г. в 14:52, Sylvain Henry <<a href="mailto:hsyl20@gmail.com">hsyl20@gmail.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Hi,<br><br></div>Here is a solution using JuicyPixels:<br><br>import Codec.Picture<br>import Codec.Picture.Types<br><br><br>main :: IO ()<br>main = do<br>   Right img <- readImage "test.png"<br>   _ <- writeDynamicPng "test2.png" (dynamicPixelMap circleImage img)<br>   return ()<br><br>circleImage :: Pixel a => Image a -> Image a<br>circleImage img = generateImage (\x y -> f x y $ pixelAt img x y) edge edge<br>   where <br>      edge = min (imageWidth img) (imageHeight img)<br>      f x y a = if x'*x' + y'*y' < e'*e'<br>            then a<br>            else colorMap (const 0) a<br>         where<br>            e' = edge `div` 2<br>            x' = x - e'<br>            y' = y - e'<br><br></div>Sylvain<br></div><div class="gmail_extra"><br><div class="gmail_quote"></div></div><div class="gmail_extra"><div class="gmail_quote">2015-06-03 9:19 GMT+02:00 Geraldus <span dir="ltr"><<a href="mailto:heraldhoi@gmail.com" target="_blank">heraldhoi@gmail.com</a>></span>:<br></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi cafe!<div><br></div><div>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).</div><div><br></div><div>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?</div><div><br></div><div>[1] <a href="https://hackage.haskell.org/package/friday" target="_blank">https://hackage.haskell.org/package/friday</a></div><div>[2] <a href="https://hackage.haskell.org/package/unm-hip" target="_blank">https://hackage.haskell.org/package/unm-hip</a></div></div>
<br></blockquote></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div></div></blockquote></div>