ImageMagick Border - imagemagick

I'm trying to apply the Torn Paper Edge to a GIF I created. How can I do so?
Website: https://legacy.imagemagick.org/Usage/thumbnails/#torn

Input:
Linux or Mac Syntax:
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
Windows Syntax:
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
See https://legacy.imagemagick.org/Usage/thumbnails/#torn
Note: For ImageMagick 7, replace convert with magick.

Related

image-magic: select orientation of the stacked image

I am using montage of imagemagic to stack horizontally 3 types of image producing Nx3 table:
montage \( "${output}/type1*.png" \) \( "${output}/type2*.png" \) \( "${output}/type3*.png" \) -geometry 800x600+1+1 -frame 4 -background white -mattecolor lightgoldenrod2 -mode Frame -bordercolor white ${output}/summary.png
is it possible to add here some option in order to produce vertically-stacked table of the Nx3 elements. I found only a possibility to do it via
convert where I need to specify -apend option:
convert \( "${output}/type1*.png" -bordercolor lightgoldenrod2 -border 0x2 -append \) \( "${output}/type2*.png" -bordercolor lightgoldenrod2 -border 0x2 -append \) \( "${output}/type3*.png" -bordercolor lightgoldenrod2 -border 0x2 -append \) -bordercolor lightgoldenrod2 -border 2x0 +append -background white -alpha deactivate ${output}/summary.png
You can do that in Imagemagick by transposing all your images, do the montage, then transpose the result using pipes between convert and montage and convert.
convert lena.jpg mandril3.jpg zelda1.jpg redhat.jpg -transpose miff:- | montage - -tile 2x2 miff:- | convert - -transpose result.png

How to colorize an image with multiply to add transparency to the colour with Image Magick

I would like to colorize an image with two colours, red on the left half and green on the right half but the colorize function just adds a coloured overlay to the image rather than multiplying it on. So I would like my image to look like this but it is currently looking like this. Here is the original image
My code at the moment is this:
convert normal.png \
\( -clone 0 -crop 50x100% -fill red -colorize 60% \) \
\( -clone 0 -crop 50x100%+64 -fill green -colorize 60% \) \
-delete 0 -background none -flatten result.png
I have tried adding -compose multiply -composite to the code but I just get this which has the right effect but I cannot get it to the position that I want, heres the code for that:
convert normal.png \
\( -clone 0 -crop 50x100% -fill red -colorize 70% \) \
\( -clone 0 -crop 50x100%+64 -fill green -colorize 70% \) \
-background none -compose multiply -composite result.png
One simple approach would be to assemble the red-green overlay inside parentheses, then do a multiply composite over the input image.
magick lena_circ.png -size %wx%h \
\( xc:red xc:green +append -scale 50x100% \) \
-compose multiply -channel rgb -composite result.png
That command give me this result...

ImageMagick: How to create torn page effect for specifc edges?

The ImageMagick documentation provides guidance on how to create torn page effects (https://www.imagemagick.org/Usage/thumbnails/#torn). However, in their implementation, all edges are torn. Suppose I wish to tear off only the bottom or top part of the image. How can I achieve such a thing using ImageMagick?
Simply grow the top & sides by using -extent operator.
convert zelda.png -background pink -extent 148x138-10-10 extent.png
(Adding pink background for visibility on stack)
Apply the effect from the Usage documentation.
convert extent.png \( +clone -alpha extract -virtual-pixel black \
-spread 10 -blur 0x3 -threshold 50% -spread 1 -blur 0x.7 \) \
-alpha off -compose Copy_Opacity -composite torn.png
Then crop back to original image size.
convert torn.png -crop 128x129+10+10 output.png
Update
If you do not want to use geometry, you can use a combination of -border, -shave & -chop.
convert zelda.png -bordercolor pink -border 10x10 -gravity South -chop 0x10 extent.png
convert extent.png \( +clone -alpha extract -virtual-pixel black \
-spread 10 -blur 0x3 -threshold 50% -spread 1 -blur 0x.7 \) \
-alpha off -compose Copy_Opacity -composite torn.png
convert torn.png -shave 10x -chop 0x10 output.png
.. And of course, this all can be done with one command.
convert zelda.png -bordercolor pink -border 10x10 -gravity South -chop 0x10 \
\( +clone -alpha extract -virtual-pixel black -spread 10 -blur 0x3 -threshold 50% \
-spread 1 -blur 0x.7 \) -gravity Forget -alpha off -compose Copy_Opacity -composite \
-shave 10x -chop 0x10 output.png
There are several ways to create a torn edge effect using ImageMagick. Here is another example command using IM version 6 and *nix syntax. This should apply a torn effect to just the top edge of any input image while keeping the original dimensions of the image.
convert input.png -alpha set -background black -fill white \
\( +clone -colorize 100 -gravity south -chop 0x6 -splice 0x6 \
-spread 6 -paint 2 +transparent white -blur 0x0.5 \) \
-background none -compose dstin -composite torn.png
That creates a white mask inside the parentheses. Then a small amount of the "torn" edge is chopped off and a black strip is spliced on to replace it. The random-ish torn edge is created using "-spread" and "-paint" between the white and black areas of the mask. After that, outside the parentheses, that mask is used to apply the transparent torn area to the input image.
To apply the effect to the bottom edge, just change the "-gravity north" to "-gravity south".
To make the torn edge on the left or right, change the gravity setting to "west" or "east", and change the values of the "-chop" and "-splice" operations from "0x6" to "6x0".
This should work the same way using ImageMagick version 7 by changing the "convert" command to "magick".
To use it in Windows, remove the backslashes that escape the parentheses from "\(...\)" to "(...)", and change the continued line backslashes "\" to carets "^".

Setting opacity of each image drawn on canvas with imagemagick

I have the command below which takes multiple image sources and draw it onto 1 output.png file.
Convert img1.jpg -resize 1000x1000!
-draw "image over 169,555 875,109 'img1.png'"
-draw "image over 29,55 375,209 'img2.png'"
-draw "image over 129,525 15,29 'img3.png'"
png24:output.png
Is there a way to set the opacity of each of the images being drawn? where some might have opacity of 60% , while others have 100%
I tried this but doesn't work:
Convert img1.jpg -resize 1000x1000!
\( -alpha set -channel A -evaluate set 60% \) -draw "image over 169,555 875,109 'img1.png'"
\( -alpha set -channel A -evaluate set 100% \) -draw "image over 29,55 375,209 'img2.png'"
\( -alpha set -channel A -evaluate set 90% \) -draw "image over 129,525 15,29 'img3.png'"
png24:output.png
Thanks in advance
I think you want something like this...
convert img1.jpg -resize 1000x1000! \
\( img1.png -alpha set -channel A -evaluate set 60% -resize 707x447 \) -geometry +169+109 -composite \
\( img2.png -alpha set -channel A -evaluate set 100% -resize 347x155 \) -geometry +29+55 -composite \
\( img3.png -alpha set -channel A -evaluate set 90% -resize 115x497 \) -geometry +15+29 -composite \
png24:output.png

Create drop shadow effects in Imagemagick

The border shadow effects used in the images of this blog post seem to be embeded in the images themselves (not css3). How can it be created in imagemagick?
Edit 1:
The solution which I found quite accidentlly is posted below as an answer.
Somehow I found the command which does what I wanted exactly:
For images which are already scaled and compressed:
convert input.jpeg -bordercolor white -border 13 \( +clone -background black -shadow 80x3+2+2 \) +swap -background white -layers merge +repage output.jpg
For creating thumbnails:
convert input.jpeg -thumbnail 200x200 -bordercolor white -border 6 \( +clone -background black -shadow 80x3+2+2 \) +swap -background white -layers merge +repage output.jpg
For raw images:
convert input.jpeg -scale 600x400 -quality 86 -strip -bordercolor white -border 13 \( +clone -background black -shadow 80x3+2+2 \) +swap -background white -layers merge +repage output.jpg
There is a -shadow argument on convert that has options to do this.
http://web.archive.org/web/20120607055659/http://blog.bemoko.com/2009/07/01/add-shadow-and-border-to-images-with-imagemagick/
Shutter uses the following command https://github.com/shutter-project/shutter/blob/master/share/shutter/resources/system/plugins/perl/spshadow/spshadow#L375
convert in.png -gravity 'northwest' -background 'rgba(255,255,255,0)' -splice '10x10' \( +clone -background '#005f005f005f0000' -shadow "80x3-1-1" \) +swap -background none -mosaic +repage \( +clone -background '#005f005f005f0000' -shadow "80x3+5+5" \) +swap -background none -mosaic +repage out.png

Resources