I'm trying to create a torn edge effect in RMagick. Is there a filter similar to photoshop's crystallize?
Also, I found this ImageMagick code that does it here http://www.imagemagick.org/Usage/thumbnails/#torn:
convert thumbnail.gif \
\( +clone -alpha extract -virtual-pixel black \
-spread 10 -blur 0x3 -threshold 50% -spread 1 -blur 0x.7 \) \
-alpha off -compose Copy_Opacity -composite torn_paper.png
However, I don't understand any of it. Can anyone provide some advice?
This command does two main things: create a mask with that torn-paper effect, apply the mask to the image. It does them, fancily, in one line, by using +clone and the parentheses. It's less confusing to do it as two commmands though:
convert thumbnail.gif \
-alpha extract \
-virtual-pixel black \
-spread 10 \
-blur 0x3 \
-threshold 50% \
-spread 1 \
-blur 0x.7 \
mask.png
convert thumbnail.gif mask.png \
-alpha off \
-compose Copy_Opacity \
-composite torn_paper.png
The first command is fairly complex. But you can find decent explanations of each of the component commands in the ImageMagick docs:
Also, by splitting the command into these two pieces, you can see what the mask looks like on its own. It's basically the inverse of the paper effect. White throughout the middle of the images, fading to black around the "torn edges".
The second command is a lot more straightforward. Copy_Opacity, as described in the ImageMagick docs, is a way of making parts of an image transparent or not. Anything that's black in the mask will be made transparent in the resulting image. In effect, the second command uses the mask to "erase" the edges of the original thumbnail in a stylistically interesting way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With