Fred's ImageMagick Scripts


    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:


Transforms an image to place it in a region of a tshirt image using an external lighting and displacement map

Download Script

last modified: July 21, 2017

USAGE: tshirtwarp lightingfile displacementfile infile backgroundfile outfile

infile is the image to be placed onto the tshirt
backgroundfile is the tshirt image
lighting file and displacement files are generated by the script tshirt with the -E option.

PURPOSE: To apply an image to a region of of a tshirt image using a lighting file, a displacement map and arguments provided by the script tshirt.

DESCRIPTION: TSHIRTWARP applies an image to a region of a tshirt image using a lighting file, a displacement map and arguments provided by the script tshirt. The arguments must be copied from the tshirt script output at the terminal and pasted in the arguments section of this script.

REQUIREMENTS: IM 6.3.6-0 due to the use of the current control point ordering. Also requires the preprocessing of the tshirt script in export mode (-E) to get the lighting image (lighting.png), 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.


First Run Tshirt Script With Option -E To Get Lighting Image, Displacement Map and Terminal Listing

Input (Overlay) Image
(Source Image)

Background (Tshirt )Image
(Source Image)

-r "130x130+275+175" -R -3 -o 5,0 -E

Lighting Image

Displacement Image

Terminal Listing

coordinates="0,0 276,179 478,0 405,172 478,478 411,300 0,478 283,307"

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

Lighting Image

Displacement Image

Background (Tshirt )Image
(Source Image)

Input (Overlay) Image
(Source Image)

(none needed)

What the script does is as follows:

  • Requires that Tshirt Script be run first with option -E
    to export the lighting and displacement map image and arguments
    listed to the terminal
  • Copy and paste the arguments from the terminal into the Tshirtwarp Script
    where specified.
  • Run Tshirtwarp with the lighting image, displacement map image,
    input image and background image.