Page 2 of 3

Re: Need help converting 3d Cover!

Posted: 2011-08-05T18:17:43-07:00
by fmw42
ecoverguru wrote:Here is what would happen with masking.

Image

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

Make the mask curved at the top and bottom using -draw "arc ..." . Otherwise, you will need to use displacement mapping similar to the way I did the top and bottom of the cylinder distortion. see the link for displacement mapping earlier.

Re: Need help converting 3d Cover!

Posted: 2011-08-06T12:46:09-07:00
by ecoverguru
Hmm... So, it seems I have go with the mask method....

Well, I am trying it now.. and somehow I am not getting the transparent output .. here is my code

Code: Select all

"convert spine_mask.png   spine.png  -composite -alpha Off -compose Copy_Opacity spinenew.png"
I have tried with "-virtual-pixel transparent" but still getting the black background.

Image

Re: Need help converting 3d Cover!

Posted: 2011-08-06T13:04:57-07:00
by fmw42
try

convert spine.png spine_mask.png -alpha Off -compose Copy_Opacity -composite spinenew.png

Re: Need help converting 3d Cover!

Posted: 2011-08-06T13:22:12-07:00
by ecoverguru
Muuuhaa... :)
Worked perfectly.. let me start on the next steps... thanks a ton... will keep you updated.

Re: Need help converting 3d Cover!

Posted: 2011-08-06T13:41:23-07:00
by ecoverguru
Is there anyway to combine these 2 commands into 1?

Code: Select all

exec("convert flatcover.jpg -crop 96x710+0+0 +repage  -virtual-pixel transparent -matte +distort Perspective '0,0,0,0, 0,710,5,229, 96,0,18,6, 96,710,20,242' -sharpen 3x2 spine.png);

exec("convert spine.png spine_opac.png -alpha Off -compose Copy_Opacity -composite spinenew.png");
I tried doing this but doesn't give any output

Code: Select all

exec("convert flatcover.jpg -crop 96x710+0+0 +repage  -virtual-pixel transparent -matte +distort Perspective '0,0,0,0, 0,710,5,229, 96,0,18,6, 96,710,20,242' -composite spine_opac.png -alpha Off -compose Copy_Opacity -composite spinenew.png");
.

Re: Need help converting 3d Cover!

Posted: 2011-08-06T14:11:18-07:00
by fmw42
You need to use parenthesis

convert \( flatcover.jpg -crop 96x710+0+0 +repage -virtual-pixel transparent -matte +distort Perspective '0,0,0,0, 0,710,5,229, 96,0,18,6, 96,710,20,242' -sharpen 3x2 \) spine_opac.png -alpha Off -compose Copy_Opacity -composite spinenew.png


see http://www.imagemagick.org/Usage/basics/#parenthesis

In unix, the parenthesis needs to be escaped with \ and must have a space on each end to separate them from the command

Please post your final result when you are complete, if you can. We are interested to see how well that works out.

Re: Need help converting 3d Cover!

Posted: 2011-08-06T14:30:13-07:00
by ecoverguru
Can we save an image in between the process? eg.

covert \( do something save1.jpg) do more processing save2.jpg

?
or do I need to use separate convert command?

Re: Need help converting 3d Cover!

Posted: 2011-08-06T14:40:09-07:00
by fmw42
ecoverguru wrote:Can we save an image in between the process? eg.

covert \( do something save1.jpg) do more processing save2.jpg

?
or do I need to use separate convert command?

Yes,

convert \( do something -write save1.jpg \) do more processing save2.jpg

see http://www.imagemagick.org/Usage/files/#write

Re: Need help converting 3d Cover!

Posted: 2011-08-07T04:50:22-07:00
by anthony
One suggestion.

Curve the spine using -wave,
http://www.imagemagick.org/Usage/warping/#wave

Then use -distort Perspective finish it.

NOTE: make sure you turn on transparency background and virtual pixels. At least until you have all the pieces merged together.

Re: Need help converting 3d Cover!

Posted: 2011-08-07T20:10:21-07:00
by ecoverguru
Does the wave function allows to set different coordinates and the depth of the wave for different coordinates? cause in my situation for top and bottom need different numbers.

Re: Need help converting 3d Cover!

Posted: 2011-08-07T21:38:30-07:00
by fmw42
ecoverguru wrote:Does the wave function allows to set different coordinates and the depth of the wave for different coordinates? cause in my situation for top and bottom need different numbers.
Not that I know. It is the same throughout. But perhaps if you do that first, then the perspective, you can make it taper. But Anthony can answer that better than I as he has more experience with -wave.

Alternately, you can do the -wave and then a displacement map to make it taper.

Re: Need help converting 3d Cover!

Posted: 2011-08-07T22:26:13-07:00
by anthony
No it doesn't. The -wave 'warping' operator works much like -shear in that it shifts pixels in individual columns to generate the sine wave distortion that you specify. It will not enlarge or shrink that wave hight-wise. It just seemed to fit in with what you were after.




NOTE that when you finally get the distortion right, you can convert it into either a 'absolute distortion map' or a 'relative displacement map' for speed. If you generate those then you can edit the maps (especially the absolute map) slightly to get exactly what you want.

That is you can spend a lot of effort in generating the maps, once only, and even manually tweek the result. But once you have the complex distortion you are looking for you can then apply it to any number of images. The only problem with such maps is they generally only work against a fixed sized input/output image.

See http://www.imagemagick.org/Usage/mappin ... on_unified

yes these mapping masks were mathematically generated, but any method of generation (warps, distorts, maths, edits) can be used.

I suggest it because your distortion seems to becoming quite a complex affair, and you may not get exactly what you want with just the distortions provided, or to use them may become too slow.

Re: Need help converting 3d Cover!

Posted: 2011-08-08T02:59:00-07:00
by ecoverguru
hmm.. I don't think i will be able to use any of those commands as I am pretty bad in programming and maths. lol

Anyway, Fred "fmw42" has been a great help and here is what i am able to produce so far.

Image

will be doing some minor tweaks like gradient overlay on spine etc.. but overall I am happy with the output..

Thanks again, Fred.

Re: Need help converting 3d Cover!

Posted: 2011-08-08T17:00:40-07:00
by anthony
I like the small shading effect you have close to the spine to add the cardboard spacing.

You may like to look at other shading effects such as shown in this post
viewtopic.php?f=1&t=11726&start=15#p45566

Note the spine in this example looks curved, but actually that is a gradient effect only.

Though shading effects like this can be a mask that not only adds gradient shades, but also semi-transparent shadows
See this for the full possibilities you can get from the lighting mask, the previous post used multiple shading masks.
http://www.imagemagick.org/Usage/thumbn ... e_lighting

Perhaps you can send your final input masks and output image, as an example for others?

Re: Need help converting 3d Cover!

Posted: 2011-08-09T13:17:15-07:00
by ecoverguru
Hello Anthony, I am looking into this option of lighting mask, I am sure we will be able to tweak it further to get more realistic output. I will update with the final output.

Now, my concern is the server resources. So far I have about 9 convert commands, I guess they can be merged together? but the issue is, I need to save several outputs as well

here is the eg. process.

step1.. create spine
step2.. create frontcover
step3.. save front cover PDF ---> need to save this pdf from step2

step4.. Distort frontcover
step5.. merge spine and frontcover and create ecover (step1+4) -----> save this image as transparent use in step7

step6.. ebook without transparency ---> another save image here

Step7.. create transparent small version of step5

as you can see for each step I am using new (covert) command.

Now my question is... what is the best, optimized and less server resource intensive way?
a) using -copy or -write --- I guess it uses memory? but I read that its not good idea?
b) continue saving these images using separate convert commands?