Nick Deny Nick Deny - 1 year ago 155
Linux Question

ImageMagick, Linux Terminal

I need some help with Terminal's ImageMagick.
I need to do a mirror effect for half of input image with ONE command.

I can do this with 4 command(cut to 2 image, copy 2nd image to 1st, mirroring 1st image and then save 2 parts into one), but it's so hard for my server and sometimes lagging when lot of people try to use this function.

convert images/kek.png -crop 50%x100% images/out.jpg
cp images/out-0.jpg images/out-1.jpg
convert images/out-0.jpg -flop images/out-0.jpg
convert +append images/out-1.jpg images/out-0.jpg images/out.jpg

Answer Source

Updated Answer

I think you need something like this:

convert kek.png -crop 50x100%+0+0 \( +clone -flop \) +append result.png

enter image description here

Explanation... by specifying the +0+0 on the crop, you only get one resulting sub image (the left side) rather than two - one of which you don't need. If you specify a percentage on either dimension, the other is assumed to be a percentage too, so you don't need two percent signs. Once you have the left half, you start some "aside processing" in which you clone and flop the image. Then, after the "aside processing" is complete, you append that to the right of the original unflopped image.

Original Answer

Something like this maybe?

convert homer.png -alpha on \
      \( +clone -flip -channel A -evaluate multiply 0.4 +channel \) -append \
      granite.jpg +swap \
      -gravity North -geometry +0+5 -composite  result.png

enter image description here

Or when your Homer has a solid background:

enter image description here

Kudos to Anthony Thyssen for his excellent work here.

Start images are below:

enter image description hereenter image description here

Tags: ImageMagick, mirror, reflection, reflect

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download