> Markdown version of [/magazine/498-quick-trick-working-with-mobile-phone-data-in-images-to-create-thumbnails-and-add-meta-information](https://www.wearedevelopers.com/magazine/498-quick-trick-working-with-mobile-phone-data-in-images-to-create-thumbnails-and-add-meta-information). Every page supports `.md` or `Accept: text/markdown`. Links point to the HTML versions so they work for humans too. Agent guide: [/agents.md](https://www.wearedevelopers.com/agents.md). --- # Quick trick: working with mobile phone data in images to create thumbnails and add meta information **Published:** November 8, 2024 When you take photos with a digital camera or a mobile phone these devices add a lot of meta information directly to the file. This [exif data](https://en.wikipedia.org/wiki/Exif) in JPG and TIFF files can be a privacy issue, which I pointed out in my [TEDx talk](https://youtu.be/gnbLLQwZxeA) some time ago. The photo not only shows what you want the world to see, but also when and where it was taken. You can [remove the extra information](http://removephotodata.com/) in your browser if you want to. However, this extra information can also be a great thing to use in your products. You can access EXIF information in many different ways. \* On the command line using [exiftool](https://www.exiftool.org/) . \* In JavaScript using Jacob Seidelin's [exif.js](https://github.com/exif-js/exif-js) or Mike Kovarik's more modern [exifr](https://github.com/MikeKovarik/exifr). \* Using the [in-built functions in PHP](https://www.php.net/manual/en/ref.exif.php) or the more detailed [PEL](https://github.com/pel/pel) package which also allows to write data. \* In Python using the [exif package](https://pypi.org/project/exif/) which also does read and write. ## What data can you get from an image? Take the following photo: ![__wf_reserved_inherit](https://wearedevelopers.imgix.net/public/magazine/articles/498/images/6724efed795df002dee72aba_6724ed7efc3ddc0b2cb1a5d9_Corfu-2024-126.jpeg?w=720&fit=max&dpr=2&auto=format) If you use any of the solutions above, you can get the following information from the image. For example, in PHP you can do a: This results in: ‍ ## What can you do with data stored by your phone? This is a ton of information to play with. The classic is "[sing the GPS data to show images on a map](http://thewebrocks.com/exif/) . If you click on the different thumbnails, you can see the map moving to where the photo was taken. ‍ ![Map mashup moving a map around to where the photo was taken.](https://wearedevelopers.imgix.net/public/magazine/articles/498/images/6724efee795df002dee72ad1_6724ee27ed28e4d63f74114f_mashup2.gif) To get this information, all you need to do is read the data and then convert it. One thing not often used though is reading the altitude information. This allows you, for example, to show the [images on the height they were taken](http://thewebrocks.com/exif/height.php). ![Showing the elevation of different images](https://wearedevelopers.imgix.net/public/magazine/articles/498/images/6724efed795df002dee72abe_6724eec1a848e13c26d70665_height.gif) As the data is returned in a format like "4200/100" you need to do some parsing. This one creates an array of all images with the image name and its height in meters. Depending on the device used to take the photo there might be even more information, like the angle the camera was in and if the image is portrait or landscape. ## Using the embedded thumbnail information to improve web site performance One interesting use case is to use the embedded thumbnail information to avoid having to create thumbnails. If you check the gallery or the height example and you keep developer tools open, you can see that whilst the images are all a few megabytes, the page only reads a few hundred kilobytes. ![The gallery with browser developer tools open, showing that only 500 kilobytes were loaded whilst there are several megabytes of images.](https://wearedevelopers.imgix.net/public/magazine/articles/498/images/6724efee795df002dee72ac9_6724ef444912a1615c48070d_tranfer.png?w=720&fit=max&dpr=2&auto=format) This is because we don't load the images, or created thumbnails from them, but I use the exif thumbnail information in the JPG file instead: Originally, this thumbnail was meant to be displayed on screens built into digital cameras to have a faster preview. We can, however, also use this to preview the image without having to load it in full. In PHP this is the exif\_thumbnail() method. This will not load the whole JPG file, but only as much as it needs to get the thumbnail. This is not news. Flickr, for example, used this in the early 2000s to show you a thumbnail of the image immediately when you dragged it into the browser and then started to upload the rest. However, I have not seen it used lately. Maybe because it is too easy to create images on the cloud. Playing with Exif is fun. And why not - after all, our phones and cameras add this information anyway. ## Related Articles - [Processing 175 WeAreDeveloper World Congress talk videos in 5 hours - with PHP?](https://www.wearedevelopers.com/magazine/466-processing-175-wearedeveloper-world-congress-talk-videos-in-5-hours-with-php) - [Dev Digest 127 - putting 5 rings on it](https://www.wearedevelopers.com/magazine/464-dev-digest-127-putting-5-rings-on-it) - [Dev Digest 139 - Soft and hard queries](https://www.wearedevelopers.com/magazine/487-dev-digest-139-soft-and-hard-queries) - [Dev Digest 101 - the XXX edition](https://www.wearedevelopers.com/magazine/382-dev-digest-101-the-xxx-edition) ## Related Videos - [Hate organising your photos? Try it with 5 Terabytes](https://www.wearedevelopers.com/videos/79-hate-organising-your-photos-try-it-with-5-terabytes) - [3x Performance: A Humbling Journey](https://www.wearedevelopers.com/videos/100165-3x-performance-a-humbling-journey) - [WeAreDevelopers LIVE - Building The World’s Worst Image Editor™](https://www.wearedevelopers.com/videos/1836-wearedevelopers-live-building-the-world-s-worst-image-editor) - [Data is Key: Scraping Metadata from Websites](https://www.wearedevelopers.com/videos/708-data-is-key-scraping-metadata-from-websites) ## Related Jobs - [Digital Forensic Analyst](https://www.wearedevelopers.com/jobs/ext/1271949-digital-forensic-analyst) at **ZEISS Group** - [Digital Forensic Analyst](https://www.wearedevelopers.com/jobs/ext/1982266-digital-forensic-analyst) at **ZEISS Group** - [Remote Senior Full-Stack Engineer](https://www.wearedevelopers.com/jobs/ext/679408-remote-senior-full-stack-engineer) at **Edge Impulse** - [Remote Senior Full-Stack Engineer](https://www.wearedevelopers.com/jobs/ext/645320-remote-senior-full-stack-engineer) at **Edge Impulse** - [Senior Web Designer, Growth](https://www.wearedevelopers.com/jobs/ext/102722-senior-web-designer-growth) at **Intercom, Inc.** - [Remote Senior Full-Stack Engineer](https://www.wearedevelopers.com/jobs/ext/683045-remote-senior-full-stack-engineer) at **Edge Impulse**