Weird encoded error when using wp_generate_attachment_metadata()

I tracked the error down through several functions to GD’s imagejpeg() function.

So I checked the error log and found this:

HTTP wrapper does not support writeable connections

A quick search found that this resulted from using a full URL instead of a server filepath. So I changed the value of $filepath to use $wp_upload_dir['path'] instead of $wp_upload_dir['url']

Problem solved 🙂