
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

Hello, There is also https://hackage.haskell.org/package/JuicyPixels среда, 3 июня 2015 г., 13:19:23 UTC+6 пользователь 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

I did some combine images into a single large image code using GTK,
Cairo and Pixbuf:
https://github.com/bneijt/commitbook/blob/master/src/Rendering.hs
I would consider Cairo[1] another.
Greetings,
Bram
[1] http://cairographics.org/
On Wed, Jun 3, 2015 at 9:29 AM, Alexey Vagarenko
Hello,
There is also https://hackage.haskell.org/package/JuicyPixels
среда, 3 июня 2015 г., 13:19:23 UTC+6 пользователь 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

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

Thank you everybody!
*JuicyPixels* was the first package I have thought about, but I've mistaken
about its functionality and didn't mentioned it here.
*Sylvain*, thank you a lot! You've made my day!
ср, 3 июня 2015 г. в 14:52, Sylvain Henry
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
participants (4)
-
Alexey Vagarenko
-
Bram Neijt
-
Geraldus
-
Sylvain Henry