Jeff Utter on  wrote...
| I currently have a PHP script that does some fancy image magick stuff
| for a web gallery. As it stands now i end up having to write like 6
| temporary files in the process of getting one output. It actually only
| takes about 2-3 seconds to run on a 1mb JPG, but i have a feeling that
| coudl be made much faster and the code much simpler. I store the temp
| files as uncompressed png's as it seems to be fast and it preserves any
| alpha channel stuff used in a few of the steps. A sample of what it
| looks like can be seen at: http://sadclown.net/gallery (images are
| cached, so hopefully it won't be too slow after they are viewed once)
|
| Here's basically what i'm doing (with most of the php chopped out)
|
| # Resize the original image to 2x the final size, so it is easier to
| work with.
| convert -size {$quadx}x{$quady} '$origPath' -thumbnail x{$doubley}
| -resize '{$doublex}x<' -gravity center -crop {$doublex}x{$doubley}+0+0
| +repage -compress None '$cut_to_fit' ;
|
| #This section is some voodoo, i can't remember exactly, to get a niec,
| smooth looking AA ish font with some depth to it
| convert -size {$doublex}x60 xc:none -gravity center -stroke black
| -strokewidth 4 -pointsize 14 -annotate 0 '$title' -channel RGBA -blur
| 0x3 -stroke none -fill white -pointsize 14 -annotate 0 '$title'
| '$cut_to_fit' +swap -gravity south -geometry +0+2  -composite -compress
| None '$label_fancy' ;
| convert -size {$doublex}x -background none -gravity center -pointsize 14
| -fill white caption:'$title' -compress None '$text1' ; ";
| convert $text1 -shadow 100x4 -compress None '$outline' ;
| composite -compose over -gravity center '$text1' '$outline' -compress
| None '$text2' ;
| convert '$text2' -shadow 70x8 -compress None '$shadow' ;
| composite -compose over -gravity center '$text2' '$shadow' -compress
| None '$text3' ;
| composite -compose over -gravity south '$text3' $cut_to_fit '$label_fancy' ;
|
| #Add a white border.
| convert '$label_fancy'  -bordercolor white  -border 6 -bordercolor
| grey60 -border 1 -background  none   -rotate $randomnumber -background
| black  \( +clone -shadow 60x4+4+4 \) +swap -background  white -flatten
| -compress None '$poloroid_single' ;
|
| #convert to final image
| convert '$poloroid_single'  -resize 250x250! -strip -depth 8 -colors 256
| -quality 85 '$newPath' ;
|
| If anyone can help me clean this up, it would be greatly appreciated.
|

I took a look at the above and most of it seems fine.  However
You can combine multiple convert commands together.

Each convert command at the end has a single image.  Rather than
save it to a file, you can just continue processing that image in the
same command.

The only exception to this is if the code needs to extract some extra
data from a generated image, before proceeding.  That does not appear to
be the case.

Even the 'composite' command can be turned into a convert operation.

All the lines givem appears to be a near direct extraction from IM examples.
So none of them appear too difficult.
  http://www.cit.gu.edu.au/~anthony/graphics/imagick6/

I would however start by re-adding the line by line formating
to make the processing steps easier to see...

The last two for example can be combine as..

  convert '$label_fancy' \
          -bordercolor white  -border 6 \
          -bordercolor grey60 -border 1 \
          -background  none   -rotate $randomnumber \
          -background  black  \( +clone -shadow 60x4+4+4 \) \
                    +swap -background  white -flatten \
          -resize 250x250! -strip -depth 8 -colors 256 \
                -quality 85 -compress None \
          '$newPath'

Removing the need for '$poloroid_single'  intermedite file.

Perhaps a seperate script can be used for the image processing, to
simplify the quoting that PHP is adding to the above.

  Anthony Thyssen ( System Programmer )    <[EMAIL PROTECTED]>
 -----------------------------------------------------------------------------
     Any problem in computer science can be solved
     with one more level of indirection.        --- Morven's Metatheorum
 -----------------------------------------------------------------------------
     Anthony's Home is his Castle     http://www.cit.gu.edu.au/~anthony/

_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to