Hmm.. the source gif I'm using must be compressed. Doesn't Go handle compressed gifs in the same way? When you say 'I may get unexpected results' is that because the current gif package doesn't support compression?
On Sunday, 22 January 2017 02:47:13 UTC, andrey mirtchovski wrote: > > just as a warning, you may get unexpected results if you're working > with "compressed" gifs. i.e., file where the next frame is only the > difference between this one and the previous one. there are also > interlaced gifs, etc. i suggest you use "gifsicle" (available on > linux) to expand the gif first and then try with that if the original > doesn't work as well as you'd hoped. not sure if go's gif package > supports all optimizations. > > https://www.lcdf.org/gifsicle/ > > On Sat, Jan 21, 2017 at 4:28 PM, kalekold via golang-nuts > <golan...@googlegroups.com <javascript:>> wrote: > > I think the upload has ruined the frames. I'll try another gif tomorrow. > > > > On Saturday, 21 January 2017 16:57:15 UTC, andrey mirtchovski wrote: > >> > >> I see only a single frame in your source file. I ran your program on > >> another gif and got the expected result: > >> > >> http://i.imgur.com/HOnlU1q.gif > >> http://i.imgur.com/GnSUHQ1.gif > >> > >> On Sat, Jan 21, 2017 at 8:54 AM, kalekold via golang-nuts > >> <golan...@googlegroups.com> wrote: > >> > Hi, > >> > > >> > I'm trying to draw some text on an animated gif and I'm having a few > >> > problems. > >> > > >> > I have a source gif (attached as fire.gif) which I can decode fine > and > >> > pass > >> > the frames to the drawing lib. > >> > The problem occurs when I'm trying to replace the original frames > with > >> > ones > >> > I've modified. I always seem to get the same result (see attached > >> > out.gif). > >> > The text seems to be drawn fine but the other frames which contain > the > >> > animation seem to be missing. > >> > > >> > Here's the code: > >> > > >> > package main > >> > > >> > import ( > >> > "image" > >> > "image/draw" > >> > "image/gif" > >> > "log" > >> > "os" > >> > > >> > > >> > "github.com/fogleman/gg" > >> > ) > >> > > >> > func main() { > >> > > >> > in, err := os.Open("/home/gary/Desktop/fire.gif") > >> > if err != nil { > >> > log.Fatalln(err) > >> > } > >> > defer in.Close() > >> > > >> > decoded, err := gif.DecodeAll(in) > >> > if err != nil { > >> > log.Fatalln(err) > >> > } > >> > > >> > for x := 0; x < len(decoded.Image); x++ { > >> > frame := decoded.Image[x] > >> > ctx := gg.NewContextForImage(frame) > >> > ctx.SetHexColor("#FFF") > >> > ctx.DrawStringWrapped("Lorem ipsum dolor sit amet", 10, 10, > 0, > >> > 0, > >> > 500, 1.4, gg.AlignLeft) > >> > > >> > palImg := image.NewPaletted(frame.Bounds(), frame.Palette) > >> > draw.FloydSteinberg.Draw(palImg, frame.Bounds(), ctx.Image(), > >> > image.ZP) > >> > > >> > decoded.Image[x] = palImg > >> > } > >> > > >> > out, err := os.Create("/home/gary/Desktop/out.gif") > >> > if err != nil { > >> > log.Fatalln(err) > >> > } > >> > defer out.Close() > >> > > >> > err = gif.EncodeAll(out, decoded) > >> > if err != nil { > >> > log.Fatalln(err) > >> > } > >> > } > >> > > >> > > >> > Any ideas how to compile the changed frame to give me the correct > >> > output? > >> > > >> > -- > >> > You received this message because you are subscribed to the Google > >> > Groups > >> > "golang-nuts" group. > >> > To unsubscribe from this group and stop receiving emails from it, > send > >> > an > >> > email to golang-nuts...@googlegroups.com. > >> > For more options, visit https://groups.google.com/d/optout. > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "golang-nuts" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to golang-nuts...@googlegroups.com <javascript:>. > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.