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

TSHIRTWARP


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

Download Script

last modified: August 28, 2017



USAGE: tshirtwarp lightingfile displacementfile infile backgroundfile outfile
or
USAGE: tshirtwarp datadirectory infile backgroundfile outfile

infile is the image to be placed onto the tshirt

backgroundfile is the tshirt image

lighting file and displacement file are generated by the script tshirt with the -E option

datadirectory is specified and/or created by the tshirt script and will contain the lighting file, dispacement file and textfile of arguments named tshirtdata.txt exported using the -E and -D directory options.

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, if no directory file was specified during the running of the tshirt script. If a directory was specified, then all the images and textual data will be written to that directory and only the directory needs to be specified with the infile and backgroundfile and outfile. The latter mode with the directory permits one tshirtwarp script to be used with all style tshirts, rather than save a customized script for each style tshirt.

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.


EXAMPLES


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)

Arguments:
-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"
sharpen="1"
displace="10"
modulating=""
compose="hardlight"



Now Copy And Past the Terminal Text into the Tshirtwarp Script
in the Marked Section, Save With a New Name and Run It
( speed gain about 2x )

tshirtwarp_custom lighting.png displace.png overlayfile tshirtfile outputfile

(provide paths as needed)

Lighting Image

Displacement Image

Input (Overlay) Image
(Source Image)

Background (Tshirt )Image
(Source Image)

Arguments:
(none needed)



Alternately, Run Tshirt Script With Option -E -D path2/data_directory
(where you specify some data_directory to put all the needed files)

Input (Overlay) Image
(Source Image)

Background (Tshirt )Image
(Source Image)

Arguments:
-r "130x130+275+175" -R -3 -o 5,0 -E -D path2/data_directory

Textual Data listed At the terminal and written to a file called tshirtdata.txt in the data_directory

coordinates="0,0 276,179 478,0 405,172 478,478 411,300 0,478 283,307"
sharpen="1"
displace="10"
modulating=""
compose="hardlight"



Now Run The tshirtwarp script supplying data_directory followed by your overlayfile, tshirtfile and outputfile
( speed gain about 2x )

tshirtwarp data_directory overlayfile tshirtfile outputfile

(provide paths as needed)

Input (Overlay) Image
(Source Image)

Background (Tshirt )Image
(Source Image)

Arguments:
(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.