Page 1 of 1
Problem with polaroid effect shadows
Posted: 2009-03-01T03:04:27-07:00
by gazchap
I was using IM 6.3.5, but last night changed to the latest version on the website to see if the behaviour was different, to no avail.
I'm trying to replicate the polaroid effect seen in Anthony's IM Examples, but without using the -polaroid operator as this does too much - I don't want the slight curl in the picture/shadow for example.
So, using a JPEG image as input, I'm using the following command:
Code: Select all
convert "photo.jpg" -matte -thumbnail "420x>" \
-bordercolor white -border 5 \
-bordercolor grey60 -border 1 \
-background black \( +clone -shadow 60x4+4+4 \) +swap \
-background white -flatten \
jpeg:"-"
This is the result of that command:
Not quite what I intended! If I take out the line with the shadow operator on it (the whole line) the picture becomes this:
I want the soft shadow to just appear around the edges of this, like on the IM v6 Examples page
Any help appreciated
Re: Problem with polaroid effect shadows
Posted: 2009-03-01T04:14:13-07:00
by Bonzo
This works for me with 6.4.0
Used php on my local server
If I escaped the ( and ) I had the same result as you - may be a windows problem as on my host I have to escape the ( and ).
Code: Select all
<?php
$cmd = "convert attach2.jpg -matte -thumbnail \"420x>\" ".
" -bordercolor white -border 5 ".
" -bordercolor grey60 -border 1 ".
" -background black ( +clone -shadow 60x4+4+4 ) +swap ".
" -background white -flatten ";
exec("convert $cmd gazchap.jpeg");
?>
<img src="gazchap.jpeg">
Re: Problem with polaroid effect shadows
Posted: 2009-03-01T05:53:35-07:00
by gazchap
Aah, brilliant
Ta muchly, I'm using a Windows host for testing too - weird that it does that.
Re: Problem with polaroid effect shadows
Posted: 2009-03-01T20:28:28-07:00
by anthony
NOTE that your shadow offset is not correct. The blur of a shadow image extends in all directions and even further than than the offset you provided.
To do this properly replace
-flatten with
-layers merge +repage that will get you a correct offset result regardless of what direction the shadow offset falls.
See IM Examples, Shadows, for more details
http://www.imagemagick.org/Usage/convolve/#shadow
Re: Problem with polaroid effect shadows
Posted: 2009-03-03T05:20:27-07:00
by gazchap
What version did -shadow and +clone become available? And +swap for that matter?
I'm using 6.4.8 at home and on the live server they're only running 6.0.7 (and can't upgrade it apparently) and the script doesn't work until I comment out the +clone line.
Re: Problem with polaroid effect shadows
Posted: 2009-03-04T10:48:41-07:00
by Bonzo
Try this code I used on another site:
Code: Select all
/* Removed as the IM version is toooooo old
// Large image with drop shadow
exec("convert $value -matte -resize 560x450 \( +clone -background black -shadow 90x3+15+15 \) +swap -gravity northwest -geometry -3-3 -composite -background white -flatten +repage $photo");
*/
// Large image with drop shadow
// Resize original and save a temp version
exec("convert $value -resize 560x450 tmp/temp.png");
// Use the temp image to create the shadow
exec("convert tmp/temp.png -depth 8 -threshold 0 -colorize 18,18,18 -negate -bordercolor white -border 20x20 -gaussian 0x3 -shave 15x15 tmp/shadow.png");
// Put the temp image over the shadow and save
exec("composite tmp/temp.png -gravity center -geometry -10-10 tmp/shadow.png $photo");
// cleanup temp files
unlink('tmp/temp.png');
unlink('tmp/shadow.png');
Could probably be condensed bit if required and lose at least 1 tempory image although you will need to add your borders.
Re: Problem with polaroid effect shadows
Posted: 2009-03-04T16:32:27-07:00
by anthony
gazchap wrote:What version did -shadow and +clone become available? And +swap for that matter?
I'm using 6.4.8 at home and on the live server they're only running 6.0.7 (and can't upgrade it apparently) and the script doesn't work until I comment out the +clone line.
+clone +swap and parentheses which were added in the very early days of IM, which is why you have then in 6.0.7. Shadowing was a common problem, but complex to work out, and was added much later, about 2005 or so (some where in v6.2 I think)
The -layers merge was a even later addition at v6.3.6-2
I really suggest that you have your ISP update as 6.0.7 is now ridiculously old.