« Overlay image for Ima… | Home | Colorize JSON or XML … »

Gradients in GraphicsMagick

Did you know you can make Gradients with GraphicsMagick?

You can simply load an image with given size from a string specification with gradient as codec. It takes as parameters two color specifications, either as names or numeric values. With hex notation you can use #ffff00 for yellow as example.

e.g. "gradient:white-black" creates a gradient from white to black. Or "gradient:#20a0ff-#ffff00;" creates the gradients on the right with color effect from blue to yellow.

For FileMaker:

Set Variable [ $image ; Value: MBS( "GMImage.New"; "200x200"; "white" ) ]
Set Variable [ $r ; Value: MBS( "GMImage.Read"; $image; "gradient:#20a0ff-#ffff00;" ) ]
Set Field [ Contacts::Photo Container ; MBS( "GMImage.WriteToPNGContainer"; $image; "gradient.png") ]
Set Variable [ $r ; Value: MBS( "GMImage.Destroy"; $image) ]

For Xojo:

dim g as new GMGeometryMBS(200, 200)
dim i as new GMImageMBS(g, new GMColorMBS(&cFFFFFF))

i.read "gradient:#20a0ff-#ffff00;"

Backdrop = i.CopyPicture

Both snippets create a picture like the one on the right side.
The new GMImage.Read function is coming soon in next MBS FileMaker Plugin 8.3.
25 05 18 - 19:01