Wrapping effect using Imagick

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
alexlsg
Posts: 45
Joined: 2016-08-03T08:04:20-07:00
Authentication code: 1151

Wrapping effect using Imagick

Post by alexlsg »

Hey guys,

How can I have this "wrapping" effect using imagemagick?

https://gyazo.com/9ef1dd103b7bc01846fa44e6d8d43d3b

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

Re: Wrapping effect using Imagick

Post by snibgo »

See my pages "Coffee mug" and "Cylinders".
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Wrapping effect using Imagick

Post by fmw42 »

If on Unix (Linux, Mac OSX, Windows with Cygwin, Windows 10), see my scripts, cylinderize and cylinderwarp at my link below. You could run these using PHP exec().

Please always provide your IM version and Platform, since syntax may differ.
alexlsg
Posts: 45
Joined: 2016-08-03T08:04:20-07:00
Authentication code: 1151

Re: Wrapping effect using Imagick

Post by alexlsg »

snibgo wrote:See my pages "Coffee mug" and "Cylinders".
Hi Snibgo, thanks a lot for your reply. Awesome, exactly what I was looking for!
Yours is actually a lot better than the example I sent, your lighting setup is SUPERB! ; )

Is it possible to create the displacement map profile on Photoshop (se I could create different maps for many objects), and then import the profile on IM?

My idea is to create the mockup on Photoshop, and the export to IM in separate layers (shadows, displacement maps), so I can have users to create ultra realistic mockups online using IM.

Could you offer your paid service to integrate this feature on my website?

thanks!
alexlsg
Posts: 45
Joined: 2016-08-03T08:04:20-07:00
Authentication code: 1151

Re: Wrapping effect using Imagick

Post by alexlsg »

fmw42 wrote:If on Unix (Linux, Mac OSX, Windows with Cygwin, Windows 10), see my scripts, cylinderize and cylinderwarp at my link below. You could run these using PHP exec().

Please always provide your IM version and Platform, since syntax may differ.

Thanks Fred! We are using 3.4.1, with Wordpress hosted at WP Engine. Your scripts collection are impressive!

Had a look at the cylinderwarp, and since I am not technical (small business owner here) I am not sure what you approach differs from Snigbdo. It looks like Snigbd's sources the lighting/ray layer to make the displacement. Is that correct?

thanks!
alexlsg
Posts: 45
Joined: 2016-08-03T08:04:20-07:00
Authentication code: 1151

Re: Wrapping effect using Imagick

Post by alexlsg »

alexlsg wrote:
snibgo wrote:See my pages "Coffee mug" and "Cylinders".
Hi Snibgo, thanks a lot for your reply. Awesome, exactly what I was looking for!
Yours is actually a lot better than the example I sent, your lighting setup is SUPERB! ; )

Is it possible to create the displacement map profile on Photoshop (se I could create different maps for many objects), and then import the profile on IM?

My idea is to create the mockup on Photoshop, and the export to IM in separate layers (shadows, displacement maps), so I can have users to create ultra realistic mockups online using IM.

Could you offer your paid service to integrate this feature on my website?

thanks!

Since it's another topic, I created another thread to discuss on how to have separate layers:

viewtopic.php?f=18&t=30234&p=136111#p136111

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

Re: Wrapping effect using Imagick

Post by snibgo »

I don't do dynamic web sites, or PHP, or Photoshop. Sorry.
alexlsg wrote:It looks like Snigbd's sources the lighting/ray layer to make the displacement. Is that correct?
No. My "Cylinders" page calculates the displacement map with maths. My "Coffee mug" page uses a 3D ray-tracer to distort the identity map, and the result is a displacement map.
snibgo's IM pages: im.snibgo.com
alexlsg
Posts: 45
Joined: 2016-08-03T08:04:20-07:00
Authentication code: 1151

Re: Wrapping effect using Imagick

Post by alexlsg »

snibgo wrote:I don't do dynamic web sites, or PHP, or Photoshop. Sorry.
alexlsg wrote:It looks like Snigbd's sources the lighting/ray layer to make the displacement. Is that correct?
No. My "Cylinders" page calculates the displacement map with maths. My "Coffee mug" page uses a 3D ray-tracer to distort the identity map, and the result is a displacement map.

Thanks Snigbgo,

So your "Coffee mug" would only work with a 3D ray traced rendered image (not with photoshop light layers) right?

Sorry for the newbie question... : )
What is the advantage from using a 3D ray-tracer to make the displacement map, over using a traditional "photoshop like" displacement approach? More realism?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Wrapping effect using Imagick

Post by snibgo »

I show two techniques: one uses maths, the other uses a ray-tracer. Other techniques are possible. For example, you could spend time doing a manual displacement in Photoshop or Gimp or whatever.

Advantage? The ray-tracer technique gives correct results with no effort on my part. The math technique gives nearly-correct results, likewise with no effort.
snibgo's IM pages: im.snibgo.com
alexlsg
Posts: 45
Joined: 2016-08-03T08:04:20-07:00
Authentication code: 1151

Re: Wrapping effect using Imagick

Post by alexlsg »

Got it.

So assuming I already have done the manual displacement in Photoshop, the simplest approach would be to replicate that on ImageMagick, right?

How can i do that? Exporting a Photoshop raster layer displacement map, and then setting this layer up as "displacement" on ImageMagick? Then when a user adds an artwork, it would interactively be displaced as the example I sent you?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Wrapping effect using Imagick

Post by fmw42 »

alexlsg wrote:
fmw42 wrote:If on Unix (Linux, Mac OSX, Windows with Cygwin, Windows 10), see my scripts, cylinderize and cylinderwarp at my link below. You could run these using PHP exec().

Please always provide your IM version and Platform, since syntax may differ.

Thanks Fred! We are using 3.4.1, with Wordpress hosted at WP Engine. Your scripts collection are impressive!

Had a look at the cylinderwarp, and since I am not technical (small business owner here) I am not sure what you approach differs from Snigbdo. It looks like Snigbd's sources the lighting/ray layer to make the displacement. Is that correct?

thanks!
My script cylinderize creates the displacement and lighting images internally and then warps the image onto the background. The cylinderwarp script will take exported displacement maps and arguments from cylinderize and allow you to repeatedly use them to warp the same image onto different backgrounds (all the same shape/size mug). Thus you do it once with cylinderize, then apply many times with cylinderwarp, if appropriate.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Wrapping effect using Imagick

Post by snibgo »

alexlsg wrote:How can i do that? Exporting a Photoshop raster layer displacement map, and then setting this layer up as "displacement" on ImageMagick?
In principle, sure. For example, take an identity absolute displacement map, distort that in Photoshop or anything you like, and the result is a displacement map.

Here is an identity absolute displacement map (Windows BAT syntax):

Code: Select all

%IM%convert ^
  -size 300x200 xc: ^
  -sparse-color bilinear ^
0,0,#000,^
%%[fx:w-1],0,#f00,^
0,%%[fx:h-1],#0f0,^
%%[fx:w-1],%%[fx:h-1],#ff0 ^
  idDispMap.png
Image
It can be any size you want, provided the corners are black, red, red, yellow and lime, clockwise from top-left.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Wrapping effect using Imagick

Post by fmw42 »

Is that green or properly green1 or lime, if you mean IM colornames, e.g. rgb(0,255,0)?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Wrapping effect using Imagick

Post by snibgo »

Well spotted, Fred. I mean #0f0, aka green1 aka lime. I've corrected my post.

The rule is: the red channel increase from left to right, while the green channel increases from top to bottom.
snibgo's IM pages: im.snibgo.com
alexlsg
Posts: 45
Joined: 2016-08-03T08:04:20-07:00
Authentication code: 1151

Re: Wrapping effect using Imagick

Post by alexlsg »

Hey guys, I just tried to create an absolute displacement map:

1- The goal is to replicate this label wrapping i did in Photoshop
https://gyazo.com/6a5ec4c21719c027e7ed96b896249c88

2- So I replaced the label (smart object) with this absolute displacement map
https://gyazo.com/97bffa36bcb409ec6d84c9083f832e92

- Then I applied the same deform as the one the label had
https://gyazo.com/e0dc2fb548d375ec7db6cbdc0d05233d

Is this method of creating the map correct?
Post Reply