Page 3 of 3

Re: Wrapping effect using Imagick

Posted: 2016-08-17T17:45:21-07:00
by snibgo
alexlsg wrote:... and send the results here.
Please post them as links to image files. The actual files you create, not screenshots, and not movies of screenshots.

Re: Wrapping effect using Imagick

Posted: 2016-08-17T17:52:44-07:00
by fmw42
I have moved this post to this forum, since it was primarily related to PS and SVG and not Imagick and probably not really Imagemagick. If this is really about Imagemagick, then I can move this to the Users forum, if you request it.

Re: Wrapping effect using Imagick

Posted: 2016-08-19T15:55:44-07:00
by alexlsg
Snigbo, now I think I found my mistake. I used an ABSOLUTE Map (same as the one you proposed, and distorted: ... t.png?dl=0

With the goal of creating a perspective distortion like this: ... M.png?dl=0

But it didn't work. Reading your comments again, you mentioned that on SVG, you need a RELATIVE Map.

Since I do not know how to convert from ABSOLUTE to RELATIVE... Is there a relative map image I can use as a base to distort and use a SVG displacement map?


Re: Wrapping effect using Imagick

Posted: 2016-08-20T00:28:43-07:00
by snibgo
The identity relative map is constant 50% gray, so distorting it doesn't change it; it remains a constant 50% gray. If we want to distort an identity map to get a distortion map, we have to distort the identity absolute map. The distorted result is an absolute distortion map, which we can convert to a relative distortion map using:

Code: Select all

relative = absolute - ident_absolute + 50%
The following converts an absolute map to a relative map. Windows BAT syntax.

Code: Select all

set IDENT=^

%IM32i%convert ^
  abs_map.png ^
  ( +clone ^
    -sparse-color bilinear "%IDENT%" ^
  ) ^
  -compose Mathematics ^
    -define compose:args=0,-1,1,0.5 ^
    -composite ^
  +depth ^
If your images have thousands of pixels in each dimension, for best quality you should work with Q32 or higher, and save maps as Q32 or higher. Your displacement map is 7500x7000 but only 8 bits/channel/pixel, so the results will be horrible.

Don't save maps in lossy formats (eg jpeg).

Re: Wrapping effect using Imagick

Posted: 2016-08-20T12:52:41-07:00
by alexlsg
Thanks for the feedback! Will try to make a 64 bits map then.

The workflow you mentioned is out of my abilities to do in IM.

Is is possible to do the same in Photoshop? I googled a lot the past 2 weeks, but dit
not find any tutorial on creating absolute and relative maps in PS.

We managed to make the SVG displacement work, here is the code:

Now I need to make proper maps (the one I use on the example I found on a tutorial)

Re: Wrapping effect using Imagick

Posted: 2016-08-20T15:37:52-07:00
by snibgo
I don't know Photoshop. I expect you can convert from absolute to relative in PS (or Gimp), but I don't know how.

Note that Q32 means 32 bits/channel/pixel.

Re: Wrapping effect using Imagick

Posted: 2016-08-24T10:26:57-07:00
by alexlsg
Hi Snibgo, this script is based on the tutorial bellow "Changing the absolute source values to relative values".

On the attached file you can find:
pspmap.png (image I replaced)
pspmaporiginal.png (correct example image)

However the generated map is not correct. Probably something wrong with the image settings I replaced?

Changing the absolute source values to relative values.
That one is a little more complicated. Since feDisplacementMap doesn’t really allow you to map a source pixel directly to a target pixel we have to subtract the position of the pixel to convert the absolute position we have so far into a relative position. So basically, you have to load the image we created into something that can run a bit of code on each pixel and run something like the following code on each (you can just save this script and exchange the source image path for yours):


Re: Wrapping effect using Imagick

Posted: 2016-08-24T11:27:58-07:00
by snibgo
I'm lost. What are you asking?

I showed you how to convert an absolute map to relative, at the command line. If you prefer javascript, then feel free. But I can't debug your javascript code. Sorry.

Re: Wrapping effect using Imagick

Posted: 2016-08-24T11:41:33-07:00
by alexlsg
This is a script I found, not mine. Sadly I can't code, nor use command line to make an absolute map.

I thought this script could be useful/interesting for you also, this is why I shared. I'm not asking for you to debug anything.

Anyways, I apologise if it sounded inappropriate.

Re: Wrapping effect using Imagick

Posted: 2016-08-24T11:43:19-07:00
by alexlsg
BTW, my question was if the source absolute map was correct, not the code itself.

The code is correct, and I sent because I thought you might find interesting and useful for your own projects