Page 1 of 1

How to have shadow in a .jpg [solved]

Posted: 2007-03-26T13:36:02-07:00
by jaano
Hi all
v.6.3.3
I have some difficulties with shadow.
It works good with png, but I don't use it for thumbnails but for 640x480 sized pictures but the filesize increases very fast, some pictures make it over 1MB in png.
If I try flattening to jpg, the shadow just disappears and I'm having a grey area around my picture.

Here is the code snipplets:

convert in.jpg -size 800x600 -quality 90 -bordercolor \ white -border 20 -gravity center -extent 640x640 \ +repage -bordercolor grey -border 1 -flatten \
\( +clone -shadow 30x10+10+10 \) \
+swap -background none -flatten -depth 8 out.jpg

however it works using png as output, but not with jpg

any hints?

best regards and thanks
Patrick

Re: Schadow influences filesize and howto have one in a .jpg?

Posted: 2007-03-26T16:54:23-07:00
by anthony
JPEG does not allow transparency. Flattening to a background of NONE is useless
The shadow dissappears because ALL the background which was partically semi-transparent grey, becomes opaque grey when you save to JPEG. That is the whole background becomes shadow!

Change the final 'none' to white or some other color and the shadow will reappear as you nolonger have semi-transparent grey shadow, but various shades from white to grey.

Re: Schadow influences filesize and howto have one in a .jpg?

Posted: 2007-03-27T14:38:40-07:00
by jaano
actually that still gives the same result! both ways! background none and background white!

Re: Schadow influences filesize and howto have one in a .jpg?

Posted: 2007-03-27T21:26:07-07:00
by anthony
Opps reading JPEG also does not give you a transparency to work with. Also add -matter just afetr reading the JPEg image. You also have too many -flattens and never actually set a background color for the shadow.

Code: Select all

convert injpg -matte \
       -bordercolor white -border 20 \
       -gravity center -extent 640x640 \
       -bordercolor grey -border 1 \
       \( +clone -background black -shadow 30x5+10+10 \) \
      +swap -background white -flatten \
      -quality 90 out.jpg 

Re: Schadow influences filesize and howto have one in a .jpg?

Posted: 2007-03-27T23:33:52-07:00
by jaano
Thank you for your help, the -matte option made it work.