Page 1 of 4
convert a picture to a 3D DVD cover
Posted: 2008-07-21T07:19:04-07:00
by Morphleus
Hi all,
it's been a while I try to find an answer to my problem: make dynamically by my dedicated server a preview like the Imandix software,
http://www.imandix.com/.
I have an example:
src image
preview image generetad thanks to Imandix
I read all topics related to that and I can do that
take the different part of my orignal picture
Code: Select all
convert img.jpg -gravity East -chop 860x0 back.jpg
convert img.jpg -gravity East -chop 759x0 -gravity West -chop 759x0 spine.jpg
convert img.jpg -gravity West -chop 841x0 front.jpg
create the good perspective of each part
Code: Select all
convert back.jpg -matte -virtual-pixel transparent -distort Perspective '0,0 60,76 0,1057 60,900 739,1057 626,910 739,0 626,62' back_cover.png
convert spine.jpg -matte -virtual-pixel transparent -distort Perspective '0,0 0,7 0,1057 0,892 81,1057 43,907 81,0 43,0' spine_cover.png
convert front.jpg -matte -virtual-pixel transparent -distort Perspective '0,0 0,0 0,1057 0,907 758,1057 551,859 758,0 551,47' front_cover.png
I try to do that without write a file between each step but no way...
I can't do a merge of all files to have my final picture (for the moment I have a file to do the shadow but I would prefer to do that directly with IM).
Thanks for your help
Edit: my final image must be in png for using transparency.
Re: convert a picture to a 3D DVD cover
Posted: 2008-07-21T11:06:17-07:00
by Bonzo
Not a great way to do it and you will not have a shadow but I have run out of time tonight to do any more, 3 less tempory images:
Code: Select all
convert input.jpg -write mpr:image +delete ( mpr:image -crop 900x1502+0+0 -matte -virtual-pixel transparent -distort Perspective '0,0 0,50 0,1502 0,1452 900,1502 900,1472 900,0 900,40' -write 480.png ) ( mpr:image -crop 200x1502+1900+0 -write 250.png ) ( mpr:image -crop 900x1502+1100+0 -matte -virtual-pixel transparent -distort Perspective '0,0 0,0 0,1502 0,1502 900,1502 800,1000 900,0 800,150' -write 100.png )
convert -size 1900x1600 xc:none -gravity west 480.png -composite -gravity center 250.png -composite -gravity east 100.png -composite -trim finnished.png
You will have to modify the co-ordiantes to suite your image but you should get the idea. Also you are going to need some processing power to deal with your images.
Re: convert a picture to a 3D DVD cover
Posted: 2008-07-21T17:54:55-07:00
by fmw42
Re: convert a picture to a 3D DVD cover
Posted: 2008-07-22T11:28:42-07:00
by Morphleus
Thanks for your help.
Sorry Bonzo but I can't use your script, I don't know why but it doesn't work when I test it. Is it possible to get back the error code or something else from IM ??
Now i can do that
my code
Code: Select all
exec ("convert -virtual-pixel transparent
\( back.jpg -matte +distort Perspective '0,0 60,75 0,1057 60,900 739,1057 625,910 739,0 625,60' \)
\( spine.jpg -matte +distort Perspective '0,0 625,35 0,1057 625,920 82,1057 680,935 82,0 680,30' \)
\( front.jpg -matte +distort Perspective '1,0 681,30 1,1057 681,935 758,1057 1230,885 758,0 1230,75' \) -background none -layers merge +repage img.png");
I can't understand why but there is no way to stick the spine and the front without a default.
Re: convert a picture to a 3D DVD cover
Posted: 2008-07-22T11:57:23-07:00
by Bonzo
Try this format to get any errors displayed:
Code: Select all
$array = array();
exec("convert input.jpg output.png 2>&1", $array);
echo "<pre>".print_r($array)."</pre>";
Re: convert a picture to a 3D DVD cover
Posted: 2008-07-23T00:12:27-07:00
by anthony
The
-distort can position each of the distorted images in the right place directly (whether it is a negative position or otherwise). Each 'layer' image can then be merged together using
-layers merge. Do not add a background until the final step.
This is the basic reason the
+distort version exists.
See the basic multiple-distort example...
http://imagemagick.org/Usage/distorts/#box3d
Re: convert a picture to a 3D DVD cover
Posted: 2008-07-23T00:48:37-07:00
by Morphleus
If I use the -distort I have something like that
By using the +distort I'm near the perfect result, but, like your example,
http://www.imagemagick.org/Usage/distorts/#box3d, between the spine and front there is a little default.
How can I make a perfect collage between spine and front ??
Re: convert a picture to a 3D DVD cover
Posted: 2008-07-23T04:19:23-07:00
by anthony
What do you mean by a little default. If the control points match the image results should match, and it looks fine to me.
The only problem I can see is that distort is currently a little 'blurry' but I have that on my list to fix during the current round of additions for distort.
Re: convert a picture to a 3D DVD cover
Posted: 2008-07-23T05:00:46-07:00
by Morphleus
The result
a zoom to the "little default" I'm speaking
there is a little vertical blank line. It's a very little detail but...
Re: convert a picture to a 3D DVD cover
Posted: 2008-07-23T17:44:32-07:00
by anthony
When selecting the image to look at the original on 'ImageShack' I can see the line you are talking about. It looks like the images did not quite join up right.
I am not certain of why this is happening. It may be the 'fuzzyness' of the current
resampling filter that is being used (which is on my todo list for the current round of additions) Try distorting using a setting of
-filter point -interpolate cubic
or even the default 'bilinear' interpolation setting. This turns of the area resampling and goes back to a simple single point interpolated 'lookup' for each pixel color.
OR it could be because the images are being stitched together using a 'over' composition. Try using
-compose add before the
-layers merge.
Please report your results, good or bad. This is a new aspect of IM, and one that will become very important as more people use it.
Re: convert a picture to a 3D DVD cover
Posted: 2008-07-24T08:10:47-07:00
by jhfry
Leave it alone... the line actually helps... In fact I would suggest you try and make it a bit more obvious. To me the line helps to make it look more like the corner of the spine. Add some shadows, darken the spine part of the image a bit, and it might just begin to look like a photo of the DVD case.
Re: convert a picture to a 3D DVD cover
Posted: 2008-07-25T02:23:29-07:00
by Morphleus
When I had your command, it gives me something like that
Code: Select all
exec ("convert layout.jpg -virtual-pixel transparent \( back.jpg -matte +distort Perspective '0,0 62,79 0,1057 62,899 739,1057 625,910 739,0 625,63' \) \( spine.jpg -matte +distort Perspective '0,0 625,37 0,1057 625,920 81,1057 680,935 81,0 680,31' \) \( front.jpg -matte +distort Perspective '0,0 680,31 0,1057 680,935 758,1057 1229,884 758,0 1229,77' \) -compose add -layers merge +repage img.png");
I added a background with shadow
Now I have 2 files,
one for generating shadow under the cover
and another for generating lights
Do you advise me to use that files or directly use IM command to generate light and shadow as I want ??
Re: convert a picture to a 3D DVD cover
Posted: 2008-07-25T03:37:45-07:00
by anthony
If the shadows and highlights don't change then using a pre-prepared template is better.
Actually you can combine BOTH shadows and highlights into the same overlay (with a perfect grey background) and add it to the image using -compose overlay or -compose highlight. Which one depends on the order of the images, otherwise they are really the same function.
However I would be interested in how you generated the highlighting images. IT would be a great technique to know.
WARNING: use -compose plus not add (my bad). The former is a proper addition with normal bounds clipping, while the latter is a 'modulus' addition, which can wrap around on the cliiping bounds, turning white to black. See IM Examples Alpha Composition for these two composition methods.
I noticed you have added soft shadow to lift the image off the page.
Do you plan to add a 'floor mirror' as well?
I have been looking for way to add surface blur and texture to mirrored images but have not had a lot of luck with this as yet (not that I am looking hard, as I have lots of other things to do too).
Re: convert a picture to a 3D DVD cover
Posted: 2008-07-30T04:38:40-07:00
by Morphleus
I did what I wanted:
I used a grey layer to do lights and shadows, it works perfectly.
But I have another issue, my background is always blank and not transparent, I forgot something ??
Code: Select all
exec ("convert layoutwm3.png -virtual-pixel transparent \( back.jpg -matte +distort Perspective '0,0 62,79 0,1057 62,899 739,1057 625,910 739,0 625,63' \) \( spine.jpg -matte +distort Perspective '0,0 625,37 0,1057 625,920 81,1057 680,935 81,0 680,31' \) \( front.jpg -matte +distort Perspective '0,0 680,31 0,1057 680,935 758,1057 1229,884 758,0 1229,77' \) -layers merge +repage img.png");
exec ("composite img.png layer.jpg -compose Overlay img.png");
P.S. I don't need to use a floor mirror, sorry
Re: convert a picture to a 3D DVD cover
Posted: 2008-07-30T10:14:05-07:00
by jhfry
Looks great... pretty damn impressive that you could pull that off with only two commands. What adds the black border?