[ANN] Google Go (golang) binding for MagickWand

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
hgfischer
Posts: 4
Joined: 2013-05-03T15:58:45-07:00
Authentication code: 6789

[ANN] Google Go (golang) binding for MagickWand

Post by hgfischer »

Hi,

I'm working in developing the full binding to ImageMagick C APIs and currently I have a lot done, but there is still a lot of work to do.

The binding lib can be found here: https://github.com/gographics/imagick and online generated docs here: http://godoc.org/github.com/gographics/imagick/imagick

I'm also porting some C examples (https://github.com/gographics/imagick/t ... r/examples) I found in the Internet to use these Go bindings, however I've got into trouble and I'm a bit lost on where the problem may be.

The problem is with the 3dlogo example: https://github.com/gographics/imagick/b ... go/main.go

I'm getting this kind of error when running it, mostly from the C API:

Code: Select all

$ ./3dlogo 
3dlogo: wand/pixel-wand.c:888: PixelGetException: Assertion `wand->signature == 0xabacadabUL' failed.
SIGABRT: abort
PC=0x7f2df9761425
signal arrived during cgo execution

github.com/gobinds/imagick/imagick._Cfunc_PixelGetException(0x289d640, 0xc2000000b0, 0x42ba51)
	github.com/gobinds/imagick/imagick/_obj/_cgo_defun.c:4933 +0x2f
github.com/gobinds/imagick/imagick.(*DrawingWand).GetLastError(0xc200000070, 0x0, 0x0)
	github.com/gobinds/imagick/imagick/_obj/_cgo_gotypes.go:3748 +0x56
github.com/gobinds/imagick/imagick.(*DrawingWand).SetFont(0xc200000070, 0xc20009b000, 0x13, 0x0, 0x0, ...)
	github.com/gobinds/imagick/imagick/_obj/_cgo_gotypes.go:3424 +0x8e
main.main()
	/home/herbert/Workspace/Go/src/github.com/gobinds/imagick/examples/3dlogo/main.go:85 +0x7f6
So, basically:

wand/pixel-wand.c:888: PixelGetException: Assertion `wand->signature == 0xabacadabUL' failed.

at:

https://github.com/gobinds/imagick/blob ... ain.go#L85

I would appreciate any help!

thanks!

Herbert G. Fischer
Last edited by hgfischer on 2013-12-06T05:26:29-07:00, edited 1 time in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: [ANN] Google Go (golang) binding for MagickWand

Post by magick »

The ImageMagick API ensures that passed structures are non-null and of the expected type. If the signatures don't match, an assertion is thrown like you received, `wand->signature == 0xabacadabUL' failed. Generally this happens if you don't properly acquire a structure, if you pass a different structure than expected, or its possible you passed a structure that has already been relinquished. Relinquishing a structure wipes the signature so the API can detect the logic error. For a PixelWand, here is an example that should work:

Code: Select all

  ExceptionType
    severity;

  PixelWand
    *background;

  background=NewPixelWand();
  if (PixelSetColor(background,"#000000") == MagickFalse)
    puts(PixelGetException(background,&severity));
  background=DestroyPixelWand(background);
hgfischer
Posts: 4
Joined: 2013-05-03T15:58:45-07:00
Authentication code: 6789

Re: [ANN] Google Go (golang) binding for MagickWand

Post by hgfischer »

Hi,

Thanks for your quick response.

After a lot of reviewing I've found out that I was calling C.PixelGetException for a DrawingWand.

best regards
hgfischer
Posts: 4
Joined: 2013-05-03T15:58:45-07:00
Authentication code: 6789

Re: [ANN] Google Go (golang) binding for MagickWand

Post by hgfischer »

UPDATE: I've forgot some "defer" keywords. Sorry. My fault.

I've got into more trouble again and I'm having a hard time discovering what is wrong. See, I'm trying to port this example to Go, using my binding: http://members.shaw.ca/el.supremo/MagickWand/3dlogo.htm but I don't even know if this example still works.

The is no much magic in the binding. I'm only encapsulating MagickWand API into Go Structs and is somehow similar to other OOP bindings.

The new error is: main: wand/magick-wand.c:181: DestroyMagickWand: Assertion `wand != (MagickWand *) ((void *)0)' failed.
at: https://github.com/gobinds/imagick/blob ... in.go#L107

which is related to MagickWand.FxImage() method at: https://github.com/gobinds/imagick/blob ... ge.go#L872

The stack trace I got is:

Code: Select all

main: wand/magick-wand.c:181: DestroyMagickWand: Assertion `wand != (MagickWand *) ((void *)0)' failed.
SIGABRT: abort
PC=0x7f5a39f98425
signal arrived during cgo execution

github.com/gobinds/imagick/imagick._Cfunc_DestroyMagickWand(0x0, 0x1)
	github.com/gobinds/imagick/imagick/_obj/_cgo_defun.c:136 +0x2f
github.com/gobinds/imagick/imagick.(*MagickWand).Destroy(0xc200000078)
	github.com/gobinds/imagick/imagick/_obj/_cgo_gotypes.go:4463 +0x28
main.main()
	/home/herbert/Dropbox/Workspace/Go/src/github.com/gobinds/imagick/examples/3dlogo/main.go:107 +0x9fd
I took some look at MagickFxImage() function to understand why it's calling DestroyMagickWand() but It's too deep into ImageMagick and I got a bit lost.

Can you help me again, please?[/size]
hgfischer
Posts: 4
Joined: 2013-05-03T15:58:45-07:00
Authentication code: 6789

Re: [ANN] Google Go (golang) binding for MagickWand

Post by hgfischer »

Hi, I've just updated the binding URLs.
Post Reply