Fred's ImageMagick Scripts



    Licensing:

    Copyright © Fred Weinhaus

    My scripts are available free of charge for non-commercial use, ONLY.

    For use of my scripts in commercial (for-profit) environments or non-free applications, please contact me (Fred Weinhaus) for licensing arrangements. My email address is fmw at alink dot net.

    If you: 1) redistribute, 2) incorporate any of these scripts into other free applications or 3) reprogram them in another scripting language, then you must contact me for permission, especially if the result might be used in a commercial or for-profit environment.

    Usage, whether stated or not in the script, is restricted to the above licensing arrangements. It is also subject, in a subordinate manner, to the ImageMagick license, which can be found at: http://www.imagemagick.org/script/license.php

CYLINDERWARP


Applies a cylinder distortion to an image using an external displacement map

Download Script

last modified: September 20, 2015



USAGE: cylinderwarp angle displacementfile infile [backgroundfile] outfile

PURPOSE: To apply a cylinder distortion to an image using a displacement map and arguments provided by the script cylinderize.

DESCRIPTION: CYLINDERIZE applies a cylinder distortion to an image using a displacement map and arguments provided by the script cylinderize. The arguments must be copied from cylinderize output at the terminal and pasted in the arguments section of this script.

ARGUMENTS:

angle ... ANGLE is the rotation of the cylinder about its axis. It is a required argument. The values are floats with -360<=angle<=360.

REQUIREMENTS: IM 6.5.3.4 due to the use of -compose displace -composite. Also requires the preprocessing of cylinderize in export mode (-E) to get the displacement image (displace.png) and to get the needed internal arguments that must be pasted in this script below.

CAVEAT: No guarantee that this script will work on all platforms, nor that trapping of inconsistent parameters is complete and foolproof. Use At Your Own Risk.


EXAMPLES


First Run Cylinderize With Option -E To Get Displacement Map and Terminal Listing

Input Image
(Source Image)

Background Image
(Source Image)

Arguments:
-E -m vertical -r 73 -l 120 -w 100 -p 5 -n 94 -e 2
-a 0 -v background -b none -f none -o +24+10

Output Image

Displacement Image

Terminal Listing

mode="vertical"
trim="no"
scale="100"
fcolor="none"
vpmethod="background"
bgcolor="none"
width="533"
height="400"
length2="30"
pwidth="533"
pheight="400"
width1=""
height1="132.725"
xc="266.5"
yc="200"
radius2="12.7247"
coords="0,0 0,0 532,0 532,0 532,132 516.04,132 0,132 15.96,132"
offsets="+24+10"
rotation="0"
wbg="240"
hbg="232"



Now Copy And Past the Terminal Text into the Cylinderwarp Script and Run It ( speed gain about 4x )

Displacement Image

Input Image
(Source Image)

Background Image
(Source Image)

Arguments:
0



Animation

Displacement Image

Input Image
(Source Image)

Background Image
(Source Image)

Animation Code:

(
for ((i=0; i<360; i=i+20)); do
echo >&2 "$i"
cylinderwarp $i displace.png wallpaper.png coffee_mug1.jpg miff:-
done
) | convert -delay 20 - -loop 0 coffee_mug1_wallpaper_anim.gif



What the script does is as follows:

  • Requires that Cylinderize Script be run first with option -E
    to export the displacement map image and arguments listed to the terminal
  • Copy and paste the arguments from the terminal into the Cylinderwarp Script
    where specified
  • Run Cylinderwarp with the displacement map image, input image and
    optionally background image with the angle argument specified