Need help converting 3d Cover!

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?".
ecoverguru
Posts: 37
Joined: 2010-10-12T12:42:53-07:00
Authentication code: 8675308

Need help converting 3d Cover!

Post by ecoverguru »

Hello guys,

I am not a pro. programmer but know quite a bit. I have a small requirement to turn a flat image into a 3d cover, I am not posting the entire image.. but just 2 parts that i am facing problem at..

I was able to use perspective but that simply throw a straight line output.. and then tried using 'BilinearReverse' and "Shephard" features but none of them helped..

Here is the flat cover

Image

and here is how the output should be..

Image

So the spine has bit curves at the bottom and top (if you look at the output in full size)... and front cover has very very slight angle where it joins the spine.

It would really be a great if someone can help me out.

Regards,

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

Re: Need help converting 3d Cover!

Post by fmw42 »

see http://www.imagemagick.org/Usage/distorts/#box3d

or if using Linux/Mac, see my unix bash shell script, 3Dbox at the link below.
ecoverguru
Posts: 37
Joined: 2010-10-12T12:42:53-07:00
Authentication code: 8675308

Re: Need help converting 3d Cover!

Post by ecoverguru »

The box3d code doesnt give those finishing values... as I said the spine has bit curves or would that be called as spherize?

I am still trying.. and here is what my first attempt is.. LOL
Image

Somehow just not able to get the right coordinates. as I am not a programmer its pretty to tough to understand the stuff..

I hope I can get some help...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need help converting 3d Cover!

Post by fmw42 »

How did you get the above? What commands? Perhaps if we see that, we might be able get the bottom also.

An approximation woul be a cylinder distortion, though I doubt my cylinderize script will be able to help. Neither would http://www.imagemagick.org/Usage/mappin ... e_cylinder. But you may get some ideas about distortions from http://www.imagemagick.org/Usage/mapping/

Do you really need the curved spine? Is is with a single color or with an image? If a single color, then you could use -draw with straight lines for sides and arcs for the top and bottom. see http://www.imagemagick.org/Usage/draw/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need help converting 3d Cover!

Post by fmw42 »

see also the example and code at viewtopic.php?t=11726
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need help converting 3d Cover!

Post by fmw42 »

perhaps you could use -draw to create a mask of the desired outline, fill it with white and put black on the outside. The use the mask to "cookie-cutter" out the shape from an image under it. That is create the binary mask image. Resize your image for the spine (after you do the perspective tranform) to the same size or vice-versa. Then put the mask into the alpha channel so that the outside is transparent.
ecoverguru
Posts: 37
Joined: 2010-10-12T12:42:53-07:00
Authentication code: 8675308

Re: Need help converting 3d Cover!

Post by ecoverguru »

I have seen that example earlier and it has straight lines no curves..

I did many tries so forgot which code generated that output.. I am trying to replicate that effect and keep you posted.. but all i know that i put some stupid values in coordinates which doesnt make sense.. anyway let me try that again.
ecoverguru
Posts: 37
Joined: 2010-10-12T12:42:53-07:00
Authentication code: 8675308

Re: Need help converting 3d Cover!

Post by ecoverguru »

Its not plain color its going to be an ecover so there are going to be gradients, images, horizontal lines in between as image

as above, it cannot be cropped either as there are going to be lines inbetween

here is the command i used to generated earlier output.

Code: Select all

exec("convert flat_cover.jpg -crop 109x802+0+0 +repage -virtual-pixel transparent -matte +distort Polynomial '1.5  \ 
	0,0 0,0   802,0 403,33   802,109 390,36   0,128 0,123' spine.png");
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need help converting 3d Cover!

Post by fmw42 »

see my notes about using -draw above. perhaps that will give the appearance of a curved spine though only the top and bottom will be curved.
ecoverguru
Posts: 37
Joined: 2010-10-12T12:42:53-07:00
Authentication code: 8675308

Re: Need help converting 3d Cover!

Post by ecoverguru »

I understand what you are saying.. but the output wont be what it should be.

see this is how the images going to be.

Image

if we just mask that the rest of the stuff will be straight and wont give that effect
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need help converting 3d Cover!

Post by fmw42 »

this just gives me straight sides and slanted top and bottom.


convert -size 109x802 xc:darkgreen -virtual-pixel transparent -matte +distort Polynomial '1.5 \
0,0 0,0 109,0 109,100 109,802 109,802 0,802 0,702' spine.png
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need help converting 3d Cover!

Post by fmw42 »

ecoverguru wrote:I understand what you are saying.. but the output wont be what it should be.

see this is how the images going to be.

Image

if we just mask that the rest of the stuff will be straight and wont give that effect
You first have to do the perspective transformation, then use the mask on that.
ecoverguru
Posts: 37
Joined: 2010-10-12T12:42:53-07:00
Authentication code: 8675308

Re: Need help converting 3d Cover!

Post by ecoverguru »

Yup... but that will not give the actual curved effect to elements near the edges like the top border and the bottom... I have used the perspective method successfully but it doesnt give that perfect one..

Here is the one generated by IM

Image

But I need those perfect curves kinda bending effect (not sure whats that called) ... I tried -wave and -shear as well.. but somehow it did not work at all..
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need help converting 3d Cover!

Post by fmw42 »

ecoverguru wrote:Yup... but that will not give the actual curved effect to elements near the edges like the top border and the bottom... I have used the perspective method successfully but it doesnt give that perfect one..

Here is the one generated by IM

Image

But I need those perfect curves kinda bending effect (not sure whats that called) ... I tried -wave and -shear as well.. but somehow it did not work at all..
That is where the mask comes in if you draw arcs at the top and bottom and straight lines for the sides (after you have done the perspective transform).
ecoverguru
Posts: 37
Joined: 2010-10-12T12:42:53-07:00
Authentication code: 8675308

Re: Need help converting 3d Cover!

Post by ecoverguru »

Here is what would happen with masking.

Image

by just cropping edges will not give the real effect...
Post Reply