Fred's ImageMagick Scripts



    Licensing:

    Copyright © Fred Weinhaus

    My scripts are available free of charge for non-commercial (non-profit) 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

    Please read the Pointers For Use on my home page to properly install and customize my scripts.

OUTFITWARPER


Transforms a pattern image to place it over an image of some piece of clothing or outfit

Download Script

last modified: December 15, 2018



USAGE: outfitwarper [-r reduce] [-m modulate] [-x xroll] [-y yroll] [-o orientation] [-d displace] [-D directory] infile bgfile outfile

or

USAGE: outfitwarper [-r reduce] [-m modulate] [-x xroll] [-y yroll] [-o orientation] [-d displace] [-D directory] lightingfile displacementfile maskfile infile bgfile outfile

USAGE: outfitwarper [-help|-h]

-r ... reduce ........ reduction amount as percent for the infile (pattern image)
...................... before tiling it; integer>=0; default=10
-m ... modulate ...... modulation (lightness, saturation, hue) for the infile
...................... (pattern image) before tiling it; comma separate triplet
...................... L,S,H; integers>=0; default="100,100,100" (no change)
-x ... xroll ......... roll amount in pixels for the tiled image in the horizontal
...................... dimension; integer; default=0
-y ... xroll ......... roll amount in pixels for the tiled image in the vertical
...................... dimension; integer; default=0
-o ... orientation ... orientation angle for rotation of the tiled image;
...................... -360<=integer<=360; default=0
-d ... displace ...... displacement amount when applying the displacement image;
...................... integer>=0; default=5
-D ... directory ..... directory containing all the exported data from the script
...................... outfit, including a text file called outfit.txt

infile is the pattern image to be applied to the background outfit (clothing) image

PURPOSE: Transforms a pattern image to place it over an image of some piece of clothing or outfit.

DESCRIPTION: OUTFITWARPER transforms a pattern image to place it over an image of same piece of clothing or outfit. The transformed image will display hightlights from the outfit image and be distorted to match the wrinkles in the outfit image. The outfitwarper script must be run once first using -E to create the lighting, displacement and mask images. This can be done with or without -D directory.

ARGUMENTS:

-r reduce ... REDUCE is the reduction amount as percent for the infile (pattern image) before tiling it. Values are integers>=0. The default=10.

-m modulate ... MODULATE is the modulation (lightness, saturation, hue) applied to the infile (pattern image) before tiling it. Values are a comma separate triplet L,S,H of integers>=0. The default="100,100,100" (no change).

-x xroll ... XROLL is the roll amount in pixels for the tiled image in the horizontal dimension. Values are integers. The default=0.

-x yroll ... YROLL is the roll amount in pixels for the tiled image in the vertical dimension. Values are integers. The default=0.

-o orientation ... ORIENTATION angle in degrees for rotation of the tiled pattern image. Values are -360<=integer<=360; default=0.

-d displace ... DISPLACE is the displacement amount when applying the displacement image to distort the pattern on the background image. Values are integers>=0. The default=5.

-D directory ... DIRECTORY to write all the exported data, including a text file called outfit.txt containing the same textual parameter data as sent to terminal. The directory can be specified later in the outfitwarp script to import all the needed images and textual data.

NOTE: This script will not bend textures to conform to curved or bent arms. Special processing such as at http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=23348 will be needed, or alternately, use separate masks for each part that requires a different pattern orientation.

REQUIREMENTS: IM 6.5.3.4 due to the use of -compose displace.

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


Run The Script OUTFIT And Expert Data

Input (Pattern) Image
(source)

Background (Hoodie) Image
(source)

Arguments:
-e floodfill -b white -f 0.2 -s 10 -D /Users/fred/desktop/hoodie -E

Lighting Image In Directory Hoodie

Displacement Image In Directory Hoodie

Mask Image In Directory Hoodie

Outfitdata.txt In Directory Hoodie

displace="5"
reduce="10"
xroll="0"
yroll="0"
orientation="0"
modulate="100,100,100"
Run Time: 1.78 sec


Example 1 -- OUTFITWARPER

Input (Pattern) Image
(source)

Background (Hoodie) Image
(source)

Arguments:
-D /Users/fred/desktop/hoodie

Run Time: 1.09 sec


Example 2 -- OUTFITWARPER

Input (Pattern) Image
(source)

Background (Hoodie) Image
(source)

Arguments:
-D /Users/fred/desktop/hoodie



Example 3 -- OUTFITWARPER

Input (Pattern) Image
(source)

Background (Hoodie) Image
(source)

Arguments:
-D /Users/fred/desktop/hoodie



Example 4 -- OUTFITWARPER

Input (Pattern) Image
(source)

Background (Hoodie) Image
(source)

Arguments:
-D /Users/fred/desktop/hoodie



What the script does is as follows:

  • Converts the outfit image to grayscale
  • Adjust the grayscale image so that the average is mid gray
  • Modifies the mid gray image by adjusting the contrast to create the lighting image
  • Saves the mid gray image to create the displacement image
  • Resizes and tiles the pattern image
  • Applies the lighting image to the tiled pattern image image
  • Applies the displacement image to the lighting adjusted pattern image
  • Composites the final pattern image onto the outfit image