Page 3 of 4

Re: convert a picture to a 3D DVD cover

Posted: 2009-04-10T01:40:01-07:00
by moutonzare
anthony wrote: NOTE: in my version, the following line...

Code: Select all

              -size 1329x1026 xc:black -swap 0 +delete \ 
This creates the 'black' canvas AFTER all the distort processing was done. It then 'swaps' this black image, with the original image that was being cloned, so it is now at the start of the image sequence. The original image is then deleted.

At the start of the line the image sequence in memory is

original_cover, front, spine, back

At the end of the line it is

black_canvas, front, spine, back

Ready for the -layer operator to merge them all together.
I understand this line (I look in the doc) but when I tried it, it gave me a segfault. I think it comes from the fact that I don't have the newest version of IM (6.3.7) so I change the order a little ^^

Thank you for the explanation on parenthesis. I think I get the gist of them.

I make some test and -quality 95 and -depth 8 give me the file size for the result. Is there something else I can do to make the result lighter ?

Re: convert a picture to a 3D DVD cover

Posted: 2009-04-10T22:08:07-07:00
by anthony
moutonzare wrote:
anthony wrote: NOTE: in my version, the following line...

Code: Select all

              -size 1329x1026 xc:black -swap 0 +delete \ 
I understand this line (I look in the doc) but when I tried it, it gave me a segfault. I think it comes from the fact that I don't have the newest version of IM (6.3.7) so I change the order a little
The only thing that should need to change is that the -swap 0 many need to be given as -swap 0,-1 This was a late change, so that a single number assumes you mean to swap that last image with the one specified, a very common thing to do.
I make some test and -quality 95 and -depth 8 give me the file size for the result. Is there something else I can do to make the result lighter ?
Do you mean smaller? You could try qualitys such as 91 92 93 etc. For PNG the first digit is the gzip compression (9 is max) the second is the encoding style before compression. See IM Examples, Common File formats, PNG
http://www.imagemagick.org/Usage/formats/#png

Alternativally you can try using some of the PNG optimization utilities which are listed in that same area.

Other than that you could flatten the image to a white (or whatever color) background appropriate for your web display and save it as JPEG, which uses a very stong lossy compression method. But I would save the PNG version to for future use as well, unless you plan to re-build it again if you need it.

Your example is now present on the offical IM Examples site in 3D perspective Boxes.
http://www.imagemagick.org/Usage/distorts/#box3d
I did not include the code, but reference this discussion. If you like you real name, and a link to your real website as part of it, let me know (good for google stats :-) )

Re: convert a picture to a 3D DVD cover

Posted: 2009-04-11T08:40:12-07:00
by moutonzare
It was -swap 0 that was the cause of problem. -swap 0,-1 sorted it out like you say.

Code: Select all

convert -virtual-pixel Transparent \
        cover.png -matte -resize 1600x1074\! \
        \( -clone 0 -crop 740x0+0+0\! \
                    +distort Perspective '0,0  62,80  0,1073  62,897  739,1073  628,912  739,0  628,64' \
        \) \
        \( -clone 0 -crop 84x0+758+0\! \
                    +distort Perspective '0,0 628,38  0,1073 628,922   83,1073  688,937   83,0  688,30' \
        \) \
        \( -clone 0 -crop 758x0+842+0\! \
                    +distort Perspective '0,0 688,30  0,1073 688,937  757,1073 1228,883  757,0 1228,80' \
        \) \
        -size 1330x1026 xc:black -swap 0,-1 +delete \
        -layers merge \
        cover_light.png -compose HardLight -composite \
        cover_opacity.png -alpha Off -compose Copy_Opacity -composite \
        -resize 420x324\! -quality 95 -depth 8 preview.png

Code: Select all

convert -virtual-pixel Transparent \
        cover.png -matte -resize 1600x1074\! \
        \( -clone 0 -crop 740x0+0+0\! \
                    +distort Perspective '0,0  62,80  0,1073  62,897  739,1073  628,912  739,0  628,64' \
        \) \
        \( -clone 0 -crop 84x0+758+0\! \
                    +distort Perspective '0,0 628,38  0,1073 628,922   83,1073  688,937   83,0  688,30' \
        \) \
        \( -clone 0 -crop 758x0+842+0\! \
                    +distort Perspective '0,0 688,30  0,1073 688,937  757,1073 1228,883  757,0 1228,80' \
        \) \
        -size 1700x1026 xc:black -swap 0,-1 +delete \
        \( label.jpg -resize 510x510\! label_opacity.png -alpha Off -compose Copy_Opacity -composite \
                     -crop 410x0+100+0\! -repage +1232+229 \
        \) \
        -compose Over -layers merge \
        cover_label_light.png -compose HardLight -composite \
        cover_label_opacity.png -alpha Off -compose Copy_Opacity -composite \
        -resize 420x253\! -quality 95 -depth 8 preview.png
It seems slightly more efficient. For the file size, I checked the -quality parameters and 95 seems to give the best result. I can't output to jpg because I need the transparency.
I don't mind giving my real name and website: Jean-François Hren www.animecoversfan.com
Thank you again for your help ^^

Re: convert a picture to a 3D DVD cover

Posted: 2009-04-12T01:44:59-07:00
by anthony
You are most welcome, and I am glad it has worked out for you.

I already see you are making use of the 3D cover generator :-)

I have added your real name and a pointer to your site in IM examples, may take a day or so to appear.

Re: convert a picture to a 3D DVD cover

Posted: 2009-04-14T00:27:09-07:00
by anthony
As you are shrinking the final image perhaps you would like to try and make the final result a bit sharper.

Try adding the to start of the commnd -filter point for the +distort operators and just before any normal -resize operation, turning it off again with +filter


You can also try -set option:filter:blur 0.7 and later +set option:filter:blur to turn it off before using a -resize operator. This may make the final image too sharp, but the text does become a lot more readable, and you do get a number to control the overall blurring effect, of the Gaussian EWA filter used by distort.

These controls are talked about both in 'distort' and in 'resize' sections of IM examples.
http://www.imagemagick.org/Usage/distor ... ort_filter
http://www.imagemagick.org/Usage/resize/#filter_blur

In summery (for -distort only) -filter point replaces the area filter with a simple and fast interpolated color lookup. While the -set option:filter:blur ??? expert option, instead directly controls the 'blur factor' of the default gaussian filter being used for area filtering (a value of 1.0 is normal, mathematically correct, but fairly blurry).

The -filter point I think works best. It also makes the -distort operations a LOT faster too.
The other 'blur' control however gives more you finer control, but no speed up in the -distort.

This fine tuning is however only recommended if you do that final resize of the image reducing it by 2 to 3 times the size used for distorting the image. Also it will fall down when perspective distortion become very sever, though that is not typically the case, in this type of image processing.

Re: convert a picture to a 3D DVD cover

Posted: 2009-04-14T05:23:06-07:00
by moutonzare
Thank you for this tricks. I will try them when I will be back from a work travel ^^

Re: convert a picture to a 3D DVD cover

Posted: 2009-04-17T13:05:26-07:00
by moutonzare
Sorry for the double post. I try it and it work great. There is a real speed up for both script. I also set the gaussian blur at 0.75 for the cover and label script and 0.7 for the cover alone script. It's not too aliased and not too blurry. Here the scripts:

Code: Select all

convert -virtual-pixel Transparent \
        cover.png -matte -resize 1600x1074\! -filter point -set option:filter:blue 0.7 \
        \( -clone 0 -crop 740x0+0+0\! \
                    +distort Perspective '0,0  62,80  0,1073  62,897  739,1073  628,912  739,0  628,64' \
        \) \
        \( -clone 0 -crop 84x0+758+0\! \
                    +distort Perspective '0,0 628,38  0,1073 628,922   83,1073  688,937   83,0  688,30' \
        \) \
        \( -clone 0 -crop 758x0+842+0\! \
                    +distort Perspective '0,0 688,30  0,1073 688,937  757,1073 1228,883  757,0 1228,80' \
        \) \
        -size 1330x1026 xc:black -swap 0,-1 +delete +filter +set option:filter:blur \
        -layers merge \
        cover_light.png -compose HardLight -composite \
        cover_opacity.png -alpha Off -compose Copy_Opacity -composite \
        -resize 420x324\! -quality 95 -depth 8 preview.png

Code: Select all

convert -virtual-pixel Transparent \
        cover.png -matte -resize 1600x1074\! -filter point -set option:filter:blur 0.75 \
        \( -clone 0 -crop 740x0+0+0\! \
                    +distort Perspective '0,0  62,80  0,1073  62,897  739,1073  628,912  739,0  628,64' \
        \) \
        \( -clone 0 -crop 84x0+758+0\! \
                    +distort Perspective '0,0 628,38  0,1073 628,922   83,1073  688,937   83,0  688,30' \
        \) \
        \( -clone 0 -crop 758x0+842+0\! \
                    +distort Perspective '0,0 688,30  0,1073 688,937  757,1073 1228,883  757,0 1228,80' \
        \) \
        -size 1700x1026 xc:black -swap 0,-1 +delete +filter +set option:filter:blur \
        \( label.jpg -resize 510x510\! label_opacity.png -alpha Off -compose Copy_Opacity -composite \
                     -crop 410x0+100+0\! -repage +1232+229 \
        \) \
        -compose Over -layers merge \
        cover_label_light.png -compose HardLight -composite \
        cover_label_opacity.png -alpha Off -compose Copy_Opacity -composite \
        -resize 420x253\! -quality 95 -depth 8 preview.png
Thank you again for your help.

Re: convert a picture to a 3D DVD cover

Posted: 2009-04-22T00:30:00-07:00
by anthony
Doing both at the same time will not work. -set filter point essentially turns off the image filtering, leaving only 'interpolation' which is why it is a LOT faster. The 'blur' setting adjusts the default 'Gaussian' filter used by distort. The first, point filter will thus turn off the second!

Either option will however effect resize, usually detrimentally, so be sure to turn the modification OFF before using -resize.

If you look at the image BEFORE that final resize, the image may not look great, that is why it is not a normal way of handling things. The final resize allows you to use them.

Re: convert a picture to a 3D DVD cover

Posted: 2009-04-28T11:59:19-07:00
by vibez
thanks for the tips guys. I've been experimenting with the code posted in this topic but i'm having issues getting the filesize down to an expectable size for a website.

Currently I have a transparent image 600x463 in size but the output filesize is 372kb

Is there a way to shrink this filesize down to around 100kb or will that be too much of a quality reduction for png?

Maybe gif would be the answer?

Here is my code

Code: Select all

		exec("$convert  -virtual-pixel Transparent \
        cover.jpg -matte -resize 1600x1074\!  \
        \( -clone 0 -crop 740x0+0+0\! \
                    +distort Perspective '0,0  62,80  0,1073  62,897  739,1073  628,912  739,0  628,64' \
        \) \
        \( -clone 0 -crop 84x0+758+0\! \
                    +distort Perspective '0,0 628,38  0,1073 628,922   83,1073  688,937   83,0  688,30' \
        \) \
        \( -clone 0 -crop 758x0+842+0\! \
                    +distort Perspective '0,0 688,30  0,1073 688,937  757,1073 1228,883  757,0 1228,80' \
        \) \
        -size 1330x1026 xc:black -swap 0,-1 +delete +filter +set option:filter:blur \
        -layers merge \
        layer.jpg -compose HardLight -composite \
        opacity.jpg -alpha Off -compose Copy_Opacity -composite \
        -resize 600x463\! -quality 95 -depth 8 preview.png
		");
thanks in advance :)

Re: convert a picture to a 3D DVD cover

Posted: 2009-04-28T12:32:05-07:00
by fmw42
see png formats (PNG8) and compression (quality) at http://www.imagemagick.org/Usage/formats/#png

also if you are on Q16, try adding -depth 8


PNG8 and Gif only support boolean transparency (on/off) and not grayscale transparency.

Re: convert a picture to a 3D DVD cover

Posted: 2009-04-28T12:34:44-07:00
by vibez
fmw42 wrote:see png formats (PNG8) and compression (quality) at http://www.imagemagick.org/Usage/formats/#png

also if you are on Q16, try adding -depth 8
Hi have already tried a few suggestions on that page. pngcrush and the alternatives did very little as it seems imagemagick had already optimised the png quite well.

I'm already on depth 8. I did try 256 colours but the image then lost most of the transparency :(

Re: convert a picture to a 3D DVD cover

Posted: 2009-04-28T18:39:55-07:00
by anthony
To get a respectable compression the only real choice is JPEG.

HOWEVER:
  • JPEG compresses using a lossy algorithm (which is why it is smaller
  • It does not support transparency so you will have to flatten your image onto some solid background color, usally one matching the web page you plan to display it on
  • sharp boundaries and cartoon like images tend to produce strong wave like effects known as Ringing
See IM Examples, Common File Formats, JPEG, for more details of these problems
http://www.imagemagick.org/Usage/formats/#jpg

Re: convert a picture to a 3D DVD cover

Posted: 2010-02-06T20:22:22-07:00
by dynamitemedia
Ok i have been working on this for about 8 hours and cant figure out how to do this in php...

heres what i have...

Code: Select all

exec("convert -size 1700x1026 xc:black -virtual-pixel Transparent \( images/combined.png -matte -resize 1600x1074 \( -clone 0 -crop 740x0+0+0 +distort Perspective '0,0  62,80  0,1073  62,897  739,1073  628,912  739,0  628,64' \) \( -clone 0 -crop 84x0+758+0 +distort Perspective '0,0 628,38  0,1073 628,922   83,1073  688,937   83,0  688,30' \) \( -clone 0 -crop 758x0+842+0 +distort Perspective '0,0 688,30  0,1073 688,937  757,1073 1228,883  757,0 1228,80' \) -delete 0 \) \( images/label.jpg -resize 510x510 images/label_opacity.png -alpha Off -compose Copy_Opacity -composite -crop 410x0+100+0 -repage +1232+229 \) -compose Over -layers merge images/cover_label_light.png -compose HardLight -composite images/cover_label_opacity.png -alpha Off -compose Copy_Opacity -composite -resize 420x253 -quality 95 -depth 8 images/preview.png" );

but it wont work so many "\" and ")(" i got lost in there some where, and cant figure this out!


thanks for any assistance...

Chad
can anyone show me what the issue is?

been trying to follow this by using the examples here
http://www.rubblewebs.co.uk/imagemagick ... xplain.php
but this can't get it working

Re: convert a picture to a 3D DVD cover

Posted: 2010-10-30T12:20:56-07:00
by carloscelis
I make it (excuse my English):

Code: Select all

#!/bin/bash

# Creado por Carlos Celis Flen-Bers
wget http://img513.imageshack.us/img513/3228/imgrf9.jpg; img="imgrf9.jpg"
#img=$1;

identify -format "%w\x%h" $img
# imgrf9.jpg = 3213 px x 2125 px
# Width of spine = 213
# Width of covers 3213 - 213 = 3000; 3000 / 2 = 1500 px

# Back 1500 + Spine 213 + Front 1500 = 3213 px

# Cut front + spine = 1500 + 213 = 1713
#            East
# +______+---+------+
# |      |///|//////|
# |      |///|//////|
# |      |///|//////|
# |      |///|//////|
# +______+---+------+
convert "$img"  -gravity East -chop 1713x back.jpg
echo "Do back.jpg"

# Cut front y back = 1500 y 1500 por ambos lados
#   West       East
# +------+___+------+
# |//////|   |//////|
# |//////|   |//////|
# |//////|   |//////|
# |//////|   |//////|
# +------+___+------+
convert "$img"  -gravity East -chop 1500x  -gravity West -chop 1500x0 spine.jpg
echo "Do spine.jpg"

# Cut back + spine = 1500 + 213 = 1713
#     West
# +------+---+______+
# |//////|///|      |
# |//////|///|      |
# |//////|///|      |
# |//////|///|      |
# +------+---+______+
convert "$img"  -gravity West -chop 1713x0  front.jpg
echo "Do front.jpg"

# Transformar
# Puntos de perspectiva
# 1------2
# |      |
# |      |
# |      |
# |      |
# 3------4
# back 1500x2125
convert back.jpg -matte -virtual-pixel transparent \
 -distort Perspective '0,0 173,76   1500,0 1500,62   0,2125 173,1971   1500,2125 1500,1957' back_cover.png
echo "Creado back_cover.jpg"

# spine 213x2125
convert spine.jpg -matte -virtual-pixel transparent \
 -distort Perspective '0,0 0,62   213,0 143,76   0,2125 0,1957   213,2125 143,2013' spine_cover.png
echo "Creado spine_cover.jpg"

# front 1500x2125
convert front.jpg -matte -virtual-pixel transparent \
 -distort Perspective '0,0 0,76   1500,0 1200,47   0,2125 0,2013   1500,2125 1200,1910' front_cover.png
echo "Creado front_cover.jpg"

montage -geometry +0+0 back_cover.png \
\( spine_cover.png -crop 0x0-70+0 \) \
front_cover.png -background none caratula.png
# caratula.png 3143x2125

convert -size 16x16 -font CourierNew -pointsize 18 xc:none -annotate +3+12 '©' -flop cl.png

convert -size 150x16 -font CourierNew -pointsize 18 xc:none -annotate +3+12 'Carlos Celis' cc.png

montage -geometry +0+0 -background none cl.png cc.png carloscelis.png

ancho=`identify -format "%w" caratula.png`
anchowm=`expr $ancho / 3`; #echo $anchowm

composite \( carloscelis.png -geometry $anchowm -gravity southeast -dissolve 40% \)  caratula.png caratula-cpleft.png

#convert -trim img.png caratula.png
echo "Montage do"
http://celisflenbers.files.wordpress.co ... ratula.png :D

Re: convert a picture to a 3D DVD cover

Posted: 2010-10-31T19:20:08-07:00
by anthony
You should not have removed all the line formating! makes it very very very hard to follow the parenthesis!!!!

see PHP convert command formatting form Bonzo's RubbleWeb site...
Basic command line code format using php
http://www.rubblewebs.co.uk/imagemagick ... xplain.php