Page 1 of 1

Cut a Tshirt out of pattern image

Posted: 2016-05-26T12:52:53-07:00
by mcbain942

Could you please guide me on what the commands would be to do a cut of an image. Im new to ImageMagic and did not see anything that was exactly (only partially) to handle my issue.
We get already presized image files to go on a mens or womens tshirt (soon dress). To save spraying all the ink we would like to cut the image to predefined coordinates for each size, and type.

How do I first determine (given a template files) all the coordinates and create commands for each size and style.

how do i convert the template into coordinate numbers?

Will this work in .NET?
I can understand php, c++ if need be.

Here is a link to an example of what needs to be done.

Inside is

STYLE1__XS_TEMPLATE_FILE_PDF.pdf – outline of what needs to be CROPPED out for this size and style
STYLE1_XS_asset_before.png – this is the image before
STYLE1_XS_TEMPLATE_FILE_PHOTOSHOP_METHOD.ODS – this is some photoshop file they use to do this manually with (there is some hidden layer in here)
STYLE1_XS_TFILE_PDF_WITH_IMAGE_AND_TEMPLATE.pdf – this is what the step would look like right before its completed
STYLE1_XS_TT_asset_completed.png – this is the desired input


Re: Cut a Tshirt out of pattern image

Posted: 2016-05-26T13:03:17-07:00
by snibgo
I get:

"Sorry, the website cannot be found."

Re: Cut a Tshirt out of pattern image

Posted: 2016-05-26T13:15:03-07:00
by fmw42
Also provide your IM version and platform (presumably Window if you want the result as Magick.NET)

Re: Cut a Tshirt out of pattern image

Posted: 2016-05-26T13:30:06-07:00
by mcbain942

I am on the latest IM version for windows 7.0.1-6-Q16

Re: Cut a Tshirt out of pattern image

Posted: 2016-05-26T15:47:12-07:00
by fmw42
This works for me on IM Q16 Mac OSX. You can do this in PHP exec(). Or you would need to repost this to the Magick.NET forum for a solution using that API.

Code: Select all

dim=`convert STYLE1_XS_asset_before.png -format "%wx%h" info:`
echo "dim=$dim"
convert STYLE1_XS_asset_before.png \
\( -density 288 -colorspace sRGB STYLE1__XS_TEMPLATE_FILE_PDF.pdf -alpha off \
-resize $dim \
-background white -gravity center -extent $dim \
-bordercolor white -border 2 \
-fill black -draw "color 0,0 floodfill" \
-shave 2x2 \) \
-alpha off -compose copy_opacity -composite \
For IM 7, replace convert with magick.

Sorry, I do not understand the issue with coordinates. You have not specified and dimensions or coordinates other than the size of the colored image. The PDF is vector format, so it has no size, but can be scaled to any size. So I scaled the PDF to the size of the colored image in its maximum aspect dimension and centered the result so that it would crop out the colored image to its largest dimension.

The 2 pixel border that was added was to ensure that the floodfill can go all around the outside of your outline. The extra border is then shaved off afterwards.

Re: Cut a Tshirt out of pattern image

Posted: 2016-05-26T15:57:10-07:00
by fmw42
This was moved from the Developers forum to the Users forum

Re: Cut a Tshirt out of pattern image

Posted: 2016-06-01T08:08:39-07:00
by mcbain942

really you do not need the pdf's at all.

The input is the png. The output descired is the result(varied by some sort of image file or layer). I can get the template in a png format instead. can you send back your output while in try to convert to ImageMagick.NET

Re: Cut a Tshirt out of pattern image

Posted: 2016-06-01T09:20:03-07:00
by mcbain942
this is basically what i want to do , but with a tshirt


Ignore that the template file is a pdf, i have asked the client to send read png files with the correct size.

Re: Cut a Tshirt out of pattern image

Posted: 2016-06-01T09:29:13-07:00
by mcbain942
please delete post double

Re: Cut a Tshirt out of pattern image

Posted: 2016-06-01T14:19:15-07:00
by mcbain942
the following is the answer

Code: Select all

the following is the answer

 static void Main(string[] args)
            using (MagickImage mask = new MagickImage(@"c:\help\maskO2_XS.png"))//black where the cut would be white where the asset is
            using (MagickImage image = new MagickImage(@"c:\help\STYLE1_XS_asset_before.png"))//pattern file
                mask.Resize(image.Width, image.Height);
                image.Composite(mask, CompositeOperator.Bumpmap);