Page 2 of 2
Re: Shadow for transparent animated gif
Posted: 2015-11-19T02:38:26-07:00
by yakobom
Hi,
One more thing - when I use the code you've posted with another gif I get a very weird behavior - flickering and offset. What can be the problem with that?
Original image:
My result:
The code:
Code: Select all
convert http://www.broadheath.coventry.sch.uk/wp-content/uploads/2013/09/superman1.gif -coalesce -write mpr:img -delete 0--1 \( mpr:img -gravity northwest -extent 200x200% \) null: \( mpr:img -background '#5E5E59' -shadow 55x12-20-10 -flip -virtual-pixel Transparent +distort SRT "%w,%h 0.75,0.25 0 %[fx:1.25*w],%[fx:1.25*h]" \) -background transparent -layers composite -trim +repage animation.gif
Re: Shadow for transparent animated gif
Posted: 2015-11-19T02:40:36-07:00
by dlemstra
What is your version of ImageMagick and your operating system?
Re: Shadow for transparent animated gif
Posted: 2015-11-19T02:55:05-07:00
by yakobom
I am using version 6.9.2-5 which I have built on Ubuntu 14.04
Re: Shadow for transparent animated gif
Posted: 2015-11-19T05:14:17-07:00
by snibgo
In Fred's example, objects near the frame edges didn't move, so the final "-trim" removed the same from each frame.
If you want to crop, you should crop the same amount from each frame.
Re: Shadow for transparent animated gif
Posted: 2015-11-19T05:44:10-07:00
by yakobom
So you are saying that removing the '-trim' should give me a bigger but working gif? I've tried it, it looks pretty much the same (the size does not change, but the black background and flickering remains)
Re: Shadow for transparent animated gif
Posted: 2015-11-19T06:13:27-07:00
by snibgo
"-background None" in the first mpr cures the background opacity. Windows BAT syntax:
Code: Select all
convert ^
superman1.gif ^
-coalesce -write mpr:img ^
-delete 0--1 ^
( mpr:img -gravity northwest -background None -extent 200x200%% ) ^
null: ^
( mpr:img -background #5E5E59 -shadow 55x12-20-10 -flip ^
-virtual-pixel Transparent ^
+distort SRT "%%w,%%h 0.75,0.25 0 %%[fx:1.25*w],%%[fx:1.25*h]" ^
) ^
-background Transparent ^
-layers composite ^
t1.gif
Re: Shadow for transparent animated gif
Posted: 2015-11-19T07:40:23-07:00
by yakobom
Thanks a lot guys, this is really helpful.
One more thing I've noticed - following Fred's earlier suggestion for softening the shadow, I tried adding
Code: Select all
'-background white -compose over -flatten'
However if I put it at the end, the animation stops and it becomes a regular image... Where exactly should I put it in order to keep the animation?
Re: Shadow for transparent animated gif
Posted: 2015-11-19T10:25:44-07:00
by fmw42
Sorry, my mistake. I wanted to flatten each frame.
See snibgo's suggestion above about adding -background none. Here is his command in Unix syntax
Code: Select all
convert http://www.broadheath.coventry.sch.uk/wp-content/uploads/2013/09/superman1.gif \
-coalesce -write mpr:img -delete 0--1 \
\( mpr:img -gravity northwest -background None -extent 200x200% \) \
null: \
\( mpr:img -background '#5E5E59' -shadow 55x12-20-10 -flip -virtual-pixel \
Transparent +distort SRT "%w,%h 0.75,0.25 0 %[fx:1.25*w],%[fx:1.25*h]" \) \
-background transparent -layers composite -trim +repage animation.gif
Re: Shadow for transparent animated gif
Posted: 2015-11-19T11:24:36-07:00
by yakobom
Thanks, but I am still missing the way to flatten each frame - can you please help me with that as well?
Many thanks.
Re: Shadow for transparent animated gif
Posted: 2015-11-19T12:47:45-07:00
by fmw42
Same way, just use -background white before the -extent (or some other color, whatever you want)
Code: Select all
convert http://orig08.deviantart.net/03fe/f/2013/037/f/d/cry__poke_by_kiwa007-d5u29cm.gif \
-coalesce -write mpr:img -delete 0--1 \( mpr:img -gravity northwest -background white -extent 200x200% \) \
null: \( mpr:img -background '#5E5E59' -shadow 55x12-20-10 \
-flip -virtual-pixel Transparent +distort SRT "%w,%h 0.75,0.25 0 %[fx:1.1*w],%[fx:0.90*h]" \) \
-background transparent -layers composite -trim +repage animation2.gif
Re: Shadow for transparent animated gif
Posted: 2015-11-19T23:57:48-07:00
by yakobom
Great - I got all I needed. Thanks for the great support.
Re: Shadow for transparent animated gif
Posted: 2017-07-12T06:05:14-07:00
by Arise
I'm trying to add some shadow coming from front/left side lets say...
I've tried all kind of parameters/values but every time the shadow cast is not properly positioned starting at the feet and is badly skewed.
Also, the final image is not maintained at 256x256.
I tried with understanding the previous posts, I've arrived at affine transformations and now I'm stuck... after like 3 days of trying to understand what is going on.
Code: Select all
convert 1.png ^
-flip +distort SRT "0,0 1,-1 0" ^
( +clone -background #5E5E59 -shadow 60x5+0+0 ^
-virtual-pixel Transparent ^
+distort Affine "0,256 0,256 0,256 0,256 128,128 128,124 "^
) +swap -background Transparent -layers merge ^
-fuzz 2%% standing_shadow.png
The image I'm using: