how to create transparent nosie png?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
linjuming
Posts: 122
Joined: 2011-01-25T00:09:50-07:00
Authentication code: 8675308

how to create transparent nosie png?

Post by linjuming »

Image

Image

pattern_grid.png
Image
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: how to create transparent nosie png?

Post by anthony »

For a gradient or solid color image with transparency the best idea is to specify the color as a '#...' with alpha value component.

Generally the best way of generating complex transparency in an image is to generate a mask of the transparency wanted, and then use a CopyOpacity to transfer the mask into the color component.

For example see..
http://www.imagemagick.org/Usage/color_ ... _semitrans
http://www.imagemagick.org/Usage/canvas ... ransparent
http://www.imagemagick.org/Usage/compose/#copyopacity
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
linjuming
Posts: 122
Joined: 2011-01-25T00:09:50-07:00
Authentication code: 8675308

Re: how to create transparent nosie png?

Post by linjuming »

thanks , can you write down the code how to generate the first png (noise) and the third png (glid) ? they seems too hard for me , I test some ways but can not get the right result.

Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how to create transparent nosie png?

Post by fmw42 »

1) Either
convert -size 128x128 gradient:navy-white -attenuate 2 +noise gaussian result1.png
or
convert -size 128x128 gradient:navy-white -evaluate gaussiannoise 2 result1.png

see http://www.imagemagick.org/Usage/canvas/#gradient

Note gradients can use any color definition (names or hex values or rgb or cmyk or hsl or hsb)


2) Either
convert -size 128x128 xc:"#BCEE6888" result2.png
or
convert -size 128x128 xc:"rgba(188, 238, 104, 0.5)" result2.png

see color definitions http://www.imagemagick.org/script/color.php


3) convert -size 256x128 \
\( gradient:lightslateblue-slateblue \) \
\( pattern:crosshatch \) \
\( -clone 1 +level 40,100% \) \
\( -clone 1 -negate \) \
-delete 1 -compose over -composite tmp4.png

This is just a composite of a color gradient with a crosshatch pattern using the negate of the crosshatch as a mask
change the 40 to a lower value in +level 40,100% will make the lines darker

see http://www.imagemagick.org/script/forma ... n-patterns

This is unix. Windows users see http://www.imagemagick.org/Usage/windows/ for difference in syntax.
linjuming
Posts: 122
Joined: 2011-01-25T00:09:50-07:00
Authentication code: 8675308

Re: how to create transparent nosie png?

Post by linjuming »

Thank you ! very very great help !
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how to create transparent nosie png?

Post by fmw42 »

Glad to help
Post Reply