Preserving EXIF data when resizing images in WordPress

I reported an issue to the WordPress Core team about eighteen months ago, noting that the function which creates thumbnails of larger images in the CMS strips the EXIF data from these smaller files. This means that not only is geo information lost, but so are keywords and copyright information set in the file using programmes like Lightroom or Photoshop. Losing this information is a step away from securing digitally-marked files, and isn’t a great solution for photographers like me, who take the time to embed copyright information to every file they upload.

After a bit of to-ing and fro-ing, and intermittent research when I’ve had the time, I have found out (with Mike Schroeder‘s confirmation) that the problem lies with the GD image library in PHP, not with WordPress. GD doesn’t retain embedded EXIF information by default, so the solution is to make WordPress use ImageMagick to process images.

There’s a simple plugin detailed in this Gist, which you can easily use in your WordPress installation. (Note that switching to ImageMagick may, in some cases, slightly alter the quality of generated images. Check with your hosting provider before switching, to make sure that ImageMagick is installed on your web server.)