This may be a longshot, but I wonder if the $yellow->Write() writes to stdout in a separate thread (in the imageMagick library) and so your print statements are disjoint from the Write. One of the imageMagick forums mentioned setting the environment variable MAGICK_THREAD_LIMIT to 1. Could be that may help.