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

Re: Need help converting 3d Cover!

Post 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
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 »

try

convert spine.png spine_mask.png -alpha Off -compose Copy_Opacity -composite spinenew.png
ecoverguru
Posts: 37
Joined: 2010-10-12T12:42:53-07:00
Authentication code: 8675308

Re: Need help converting 3d Cover!

Post by ecoverguru »

Muuuhaa... :)
Worked perfectly.. let me start on the next steps... thanks a ton... will keep you updated.
ecoverguru
Posts: 37
Joined: 2010-10-12T12:42:53-07:00
Authentication code: 8675308

Re: Need help converting 3d Cover!

Post 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");
.
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 »

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

Re: Need help converting 3d Cover!

Post 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?
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: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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Need help converting 3d Cover!

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
ecoverguru
Posts: 37
Joined: 2010-10-12T12:42:53-07:00
Authentication code: 8675308

Re: Need help converting 3d Cover!

Post 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.
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: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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Need help converting 3d Cover!

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
ecoverguru
Posts: 37
Joined: 2010-10-12T12:42:53-07:00
Authentication code: 8675308

Re: Need help converting 3d Cover!

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Need help converting 3d Cover!

Post 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?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
ecoverguru
Posts: 37
Joined: 2010-10-12T12:42:53-07:00
Authentication code: 8675308

Re: Need help converting 3d Cover!

Post 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?
Post Reply