putting tile on image background is also changing need help

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
pratik123
Posts: 10
Joined: 2014-04-07T03:35:04-07:00
Authentication code: 6789

Re: putting tile on image background is also changing need h

Post by pratik123 » 2014-04-08T01:43:41-07:00

hi
i have done all the part of shirt only cuffs is remaining can you please guide me how can i achieve it.

This my pattern
http://oi62.tinypic.com/29pxn2t.jpg

This is my clone image for cuffs
http://oi57.tinypic.com/fjkx9t.jpg

i want this type of image for cuffs
http://oi61.tinypic.com/14alt9t.jpg

Thank you for help

User avatar
fmw42
Posts: 23899
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: putting tile on image background is also changing need h

Post by fmw42 » 2014-04-08T09:30:12-07:00

Best I can suggest is rotate your pattern to the direction you want it to go on both cuffs, then apply the distortion and/or shading masks

pratik123
Posts: 10
Joined: 2014-04-07T03:35:04-07:00
Authentication code: 6789

Re: putting tile on image background is also changing need h

Post by pratik123 » 2014-04-08T22:14:35-07:00

HI Thank you for reply
i am using following command

exec("convert -size 880x1200 tile:pattern.png pattern_tile.png
convert pattern_tile.png -rotate 90 +repage -gravity center -crop 440x600+0+0 +repage pattern_tile_rotate.png
convert clone.png -alpha extract clone_mask,png
convert pattern_tile_rotate.png clone_mask,png -alpha off -compose copy_opacity -composite final_cuffs.png

");

and result for cuffs images
http://oi59.tinypic.com/302zbkh.jpg

and i want exactly
http://oi61.tinypic.com/14alt9t.jpg

Can you please help what mistake given by me i am new in imagemagick
Thank you

User avatar
fmw42
Posts: 23899
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: putting tile on image background is also changing need h

Post by fmw42 » 2014-04-09T21:36:58-07:00

I am rather busy right now. Perhaps I can try this weekend. But perhaps you should process each cuff separately using similar type operations as you did with the shirt body. You may have to tune the processing separately for each cuff. You need to add a shading image by processing the mask image. As I recall you do that by composition --

convert image shadingimage -compose hardlight -composite result

But you may have to process the hardlight image first with -auto-level, or -contrast-stretch 0, so that the average graylevel is mid gray and you have both darks and lights.

pratik123
Posts: 10
Joined: 2014-04-07T03:35:04-07:00
Authentication code: 6789

Re: putting tile on image background is also changing need h

Post by pratik123 » 2014-04-11T04:59:25-07:00

Hi

I try but not success bcoz i am php developer not good in imagemagick so please help me whenever you have time...


Thank you in advance
Pratik

User avatar
fmw42
Posts: 23899
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: putting tile on image background is also changing need h

Post by fmw42 » 2014-04-11T15:19:53-07:00

try this

# line1: read pattern and mask images
# line2-3: rotate 80 deg and crop pattern for left side of image cuff
# line4: extract alpha channel from mask for left side of image
# line5: delete temp images
# line6: make clones of previous two images and put mask as alpha channel with left side pattern
# line7-8: rotate 90 deg and crop pattern for right side of image cuff
# line9: extract alpha channel from mask for right side of image
# line10: make clones of previous two images and put mask as alpha channel with right side pattern
# line11: delete pattern and temp images
# line12: clone the two half images and append
# line13: delete temp images
# line14: clone the mask image and process to reduce brightness
# line15: delete mask and use compose hardlight to add shading from the mask onto the cuffs

Code: Select all

convert pattern.png mask.png \
\( -clone 0 -write mpr:mask +delete -size 1000x1000 tile:mpr:mask \
    -rotate 80 +repage -gravity center -crop 220x600+0+0 +repage \) \
\( -clone 1 -alpha extract -gravity northwest -crop 220x600+0+0 +repage \) \
\( -clone 2 -clone 3 -alpha off -compose copy_opacity -composite \) \
-delete 2,3 \
\( -clone 0 -write mpr:mask +delete -size 1000x1000 tile:mpr:mask \
    -rotate 90 +repage -gravity center -crop 220x600+0+0 +repage \) \
\( -clone 1 -alpha extract -gravity northeast -crop 220x600+0+0 +repage \) \
\( -clone 3 -clone 4 -alpha off -compose copy_opacity -composite \) \
-delete 0,3,4 \
\( -clone 1 -clone 2 +append \) \
-delete 1,2 \
\( -clone 0 -evaluate subtract 45% \) \
-delete 0 -compose hard_light -composite cuff_result.png
http://www.fmwconcepts.com/misc_tests/d ... result.png

pratik123
Posts: 10
Joined: 2014-04-07T03:35:04-07:00
Authentication code: 6789

Re: putting tile on image background is also changing need h

Post by pratik123 » 2014-04-11T22:56:14-07:00

Hi
Thank you so much for your reply.
I try your code but only left cuff is done right cuff is blank i try but not success.
Please see following image and please let me know.

massk image
http://oi60.tinypic.com/szzzo0.jpg
Pattern image
http://oi59.tinypic.com/oj1im8.jpg
Rsult
http://oi60.tinypic.com/11cbiir.jpg

Thank you
Pratik

bijalbhavsar99
Posts: 15
Joined: 2014-04-07T03:23:42-07:00
Authentication code: 6789

Re: putting tile on image background is also changing need h

Post by bijalbhavsar99 » 2014-04-11T22:59:36-07:00

Hi Fmw42

Thanks for wonderful job you are doing.
I am very new to imagick, I have followed all section in this post.
When I have used above script to change cuff, it is not producing correct result same as http://www.fmwconcepts.com/misc_tests/d ... result.png.
It produce same as http://oi60.tinypic.com/11cbiir.jpg.

I hope you will help me for the same.
Thanks in advance
Bijal
Bijal Bhavsar :)

bijalbhavsar99
Posts: 15
Joined: 2014-04-07T03:23:42-07:00
Authentication code: 6789

Re: putting tile on image background is also changing need h

Post by bijalbhavsar99 » 2014-04-12T03:52:57-07:00

Hi Fmw42
After trying for a day,i have achieved perfect cuff.png image by using below code:
Mask Image : http://oi60.tinypic.com/szzzo0.jpg
Pattern image : http://oi59.tinypic.com/oj1im8.jpg
Result Image : http://i59.tinypic.com/23h8zv7.png

Generate left side cuff:

Code: Select all

exec('convert pattern.png mask.png \
\( -clone 0 -write mpr:mask +delete -size 1000x1000 tile:mpr:mask \
    -rotate 80 +repage -gravity center -crop 220x600+0+0 +repage \) \
\( -clone 1 -alpha extract -gravity northwest -crop 220x600+0+0 +repage \) \
\( -clone 2 -clone 3 -alpha off -compose copy_opacity -composite \) \
-delete 2,3 \
\( -clone 0 -write mpr:mask +delete -size 1000x1000 tile:mpr:mask \
    -rotate 90 +repage -gravity center -crop 220x600+0+0 +repage \) \
\( -clone 1 -alpha extract -gravity northeast -crop 220x600+0+0 +repage \) \
\( -clone 3 -clone 4 -alpha off -compose copy_opacity -composite \) \
-delete 0,3,4 \
\( -clone 1 -clone 2 +append \) \
-delete 1,2 \
\( -clone 0 -evaluate subtract 45% \) \
-delete 0 -compose hard_light -composite cuff_result1.png');
Generate Right side cuff:

Code: Select all

exec('convert pattern.png mask.png \
\( -clone 0 -write mpr:mask +delete -size 1000x1000 tile:mpr:mask \
    -rotate 90 +repage -gravity center -crop 220x600+0+0 +repage \) \
\( -clone 0 -write mpr:mask +delete -size 1000x1000 tile:mpr:mask \
    -rotate 80 +repage -gravity center -crop 220x600+0+0 +repage \) \
\( -clone 1 -alpha extract -gravity northwest -crop 220x600+0+0 +repage \) \
\( -clone 2 -clone 3 -alpha off -compose copy_opacity -composite \) \
-delete 2,3 \
\( -clone 1 -alpha extract -gravity northeast -crop 220x600+0+0 +repage \) \
\( -clone 3 -clone 4 -alpha off -compose copy_opacity -composite \) \
-delete 0,3,4 \
\( -clone 1 -clone 2 +append \) \
-delete 1,2 \
\( -clone 0 -evaluate subtract 45% \) \
-delete 0 -compose hard_light -composite cuff_result2.png'); 
Crop both cuff as per it's proportion:

Code: Select all

exec('convert   -gravity west -crop 220x600+0+0 cuff_result1.png cuff_first.png');
exec('convert   -gravity east -crop 220x600+0+0 cuff_result2.png cuff_second.png');
Now creating one single image by composite both side cuff:

Code: Select all

exec('convert -size 440x600!  xc:transparent cuff_final.png
composite -geometry 220x600+0+0  cuff_first.png cuff_final.png cuff_final.png
composite -geometry 220x600+220+0  cuff_second.png cuff_final.png cuff_final.png
');
Let me know if I was going wrong way.

Thanks in advance :)
Bijal
Bijal Bhavsar :)

snibgo
Posts: 10722
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: putting tile on image background is also changing need h

Post by snibgo » 2014-04-12T08:48:33-07:00

Another possibility is to curve the pattern so it runs parallel to the edge of the cuff. I follow the upper edge. It would be just as easy to follow the lower edge, or an average of the two edges. (Windows BAT scripts. Adjust for other languages.)

Step 1: make a mask by hand in Gimp, cuffsMask.png.

Image

Step 2: convert the mask to a relative displacement map:

Code: Select all

for /F "usebackq" %%L in (`%IM%identify -format "WW=%%w\nHH=%%h\nHH_2=%%[fx:h/2]" c.png`) do set %%L

%IM%convert cuffsMask.png ^
  -morphology ^
  Distance "1x2+0+0:0,1" ^
  -write cl_clutLineThkT_tmp.png ^
  -scale "%WW%x1^!" ^
  -negate ^
  -depth 16 ^
  -write c_clut0.png ^
  -scale "%WW%x%HH%^!" ^
  c_dispMap.png
Image

Step 3: apply the mask to the pattern, rotated by 90 degrees.

Code: Select all

%IM%convert ^
  cuffsPattern.png ^
  -rotate 90 ^
  -virtual-pixel Tile -extent %WW%x%HH% ^
  c_dispMap.png ^
  -compose Displace -set option:compose:args 0x%HH_2% -composite ^
  cuffsDisp.png
Image

Step 4: mask this by the opacity of the original.

Code: Select all

%IM%convert ^
  cuffsDisp.png ^
  blankCuffs.png ^
  -compose CopyOpacity -composite ^
  cuffsDisp2.png
Image

Then fmw's other operations can apply the shading.

The commands can be combined.

My technique here keeps the lines parallel to each other and the top edge. Ideally, it would adjust them to account for the top and bottom edges not being parallel.
Last edited by snibgo on 2014-04-12T10:40:31-07:00, edited 1 time in total.
snibgo's IM pages: im.snibgo.com

User avatar
fmw42
Posts: 23899
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: putting tile on image background is also changing need h

Post by fmw42 » 2014-04-12T10:25:11-07:00

Thank you so much for your reply.
I try your code but only left cuff is done right cuff is blank i try but not success.
Please see following image and please let me know.
It must be an IM version issue. What version of IM and platform are you using? It works just fine for me on IM 6.8.9.0 Q16 Mac OSX

See if adding -respect-parenthesis helps

Code: Select all

convert -respect-parenthesis pattern.png mask.png \
\( -clone 0 -write mpr:mask +delete -size 1000x1000 tile:mpr:mask \
    -rotate 80 +repage -gravity center -crop 220x600+0+0 +repage \) \
\( -clone 1 -alpha extract -gravity northwest -crop 220x600+0+0 +repage \) \
\( -clone 2 -clone 3 -alpha off -compose copy_opacity -composite \) \
-delete 2,3 \
\( -clone 0 -write mpr:mask +delete -size 1000x1000 tile:mpr:mask \
    -rotate 90 +repage -gravity center -crop 220x600+0+0 +repage \) \
\( -clone 1 -alpha extract -gravity northeast -crop 220x600+0+0 +repage \) \
\( -clone 3 -clone 4 -alpha off -compose copy_opacity -composite \) \
-delete 0,3,4 \
\( -clone 1 -clone 2 +append \) \
-delete 1,2 \
\( -clone 0 -evaluate subtract 45% \) \
-delete 0 -compose hard_light -composite cuff_result.png
P.S. Nice distortion effect, snibgo!

snibgo
Posts: 10722
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: putting tile on image background is also changing need h

Post by snibgo » 2014-04-12T10:58:35-07:00

fmw42 wrote:P.S. Nice distortion effect, snibgo!
The same trick could be applied to the sleeves, collar and front panels. Each one needs a mask that effectively defines the displacement, and creating this automatically in the general case is difficult. It would be a pain for thousands of blank (greyscale) shirts. But if there was one blank and thousands of cloth patterns, the same displacement (and shading) would be used for each.

See also the thread "How to unwarp an image" viewtopic.php?f=1&t=24577
snibgo's IM pages: im.snibgo.com

bijalbhavsar99
Posts: 15
Joined: 2014-04-07T03:23:42-07:00
Authentication code: 6789

Re: putting tile on image background is also changing need h

Post by bijalbhavsar99 » 2014-04-13T22:09:14-07:00

fmw42 wrote:
Thank you so much for your reply.
I try your code but only left cuff is done right cuff is blank i try but not success.
Please see following image and please let me know.
It must be an IM version issue. What version of IM and platform are you using? It works just fine for me on IM 6.8.9.0 Q16 Mac OSX

See if adding -respect-parenthesis helps

Code: Select all

convert -respect-parenthesis pattern.png mask.png \
\( -clone 0 -write mpr:mask +delete -size 1000x1000 tile:mpr:mask \
    -rotate 80 +repage -gravity center -crop 220x600+0+0 +repage \) \
\( -clone 1 -alpha extract -gravity northwest -crop 220x600+0+0 +repage \) \
\( -clone 2 -clone 3 -alpha off -compose copy_opacity -composite \) \
-delete 2,3 \
\( -clone 0 -write mpr:mask +delete -size 1000x1000 tile:mpr:mask \
    -rotate 90 +repage -gravity center -crop 220x600+0+0 +repage \) \
\( -clone 1 -alpha extract -gravity northeast -crop 220x600+0+0 +repage \) \
\( -clone 3 -clone 4 -alpha off -compose copy_opacity -composite \) \
-delete 0,3,4 \
\( -clone 1 -clone 2 +append \) \
-delete 1,2 \
\( -clone 0 -evaluate subtract 45% \) \
-delete 0 -compose hard_light -composite cuff_result.png
P.S. Nice distortion effect, snibgo!
Hi fmw42,

Thank you so much for your reply.

The above code work for me :)
I am not clear about using " -respect-parenthesis " in code, what it will do?

Thanks for your time.
Bijal
Bijal Bhavsar :)

pratik123
Posts: 10
Joined: 2014-04-07T03:35:04-07:00
Authentication code: 6789

Re: putting tile on image background is also changing need h

Post by pratik123 » 2014-04-13T22:24:17-07:00

Thank you for help its work.

Pratik

User avatar
fmw42
Posts: 23899
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: putting tile on image background is also changing need h

Post by fmw42 » 2014-04-13T22:48:59-07:00

I am not clear about using " -respect-parenthesis " in code, what it will do?
It is supposed to keep settings from working outside a given parenthesis. That is, it makes the settings local to each parenthesis and not global to the whole command. see http://www.imagemagick.org/Usage/basics/#controls

Post Reply