Most gd functions that output an image accept either a filename or a stream resource as the optional second parameter
Most gd functions that output an image accept either a filename or a stream resource as the optional second parameter

The only exception is imagexbm, which only accepts a filename (and which is optional)

vimeo/psalm,vimeo/psalm