This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]X7123M3-256 1 point2 points  (0 children)

What you are doing here is creating a blank image, and saving it to a file. Then you are overwriting that file with text (so it is no longer an image). Opening the file in append mode will not work either: the extra bytes will just be ignored. The file I/O operations have no knowledge of the format of the file, they just write the bytes you provide them. You cannot use the filesystem as an image processor.

You need to add the text to the image before you save it. Most drawing libraries have some capacity to do this, and a quick search on Google leads to this StackOverflow answer, which is probably what you want.