The DPI Metadata Converter is a JavaScript-based tool that operates entirely within your web browser. It is designed to modify the DPI (dots per inch) metadata of image files to meet specific technical requirements. Here's a detailed breakdown of how the tool works:
1. Image Upload
When you select an image file using the file Browse... button, the JavaScript `FileReader` API is used to read the contents of the file. The `FileReader` reads the image file as a Data URL, which is a base64 encoded string that represents the image data.
2. Optional DPI Input
You have the option to enter a desired DPI value into a number input field. If you leave this field blank, the tool will use a default value of 75 DPI. This value is stored in a JavaScript variable for later use.
3. Image Processing
Once the image is loaded and the DPI value is set, the tool proceeds to modify the image's DPI metadata. This process involves several key steps:
- File Conversion (if necessary): If the uploaded image is in HEIC format (commonly used by iPhones), it is first converted to JPEG format using the `heic2any` library. This library converts the HEIC file into a more widely supported JPEG format, ensuring compatibility with systems that may not accept HEIC images.
- Canvas Rendering: The image is then rendered onto an HTML5 canvas element using the `drawImage` method. This allows the tool to manipulate the image data directly.
- DPI Modification: After the image is rendered onto the canvas, the canvas content is converted back into a Blob (binary large object) using the `canvas.toBlob` method. This Blob is then converted into a base64 string, and the EXIF metadata is extracted using the `piexifjs` library. The EXIF data is modified to include the specified DPI value for both the XResolution and YResolution tags. Finally, the modified EXIF data is reinserted into the image.
4. Privacy-Preserving Processing
All of these operations—reading the image, modifying its DPI metadata, and re-encoding the image—happen entirely within your web browser. This means that your image data never leaves your device, ensuring complete privacy. The tool does not send any data to a server, and no data is stored or transmitted outside of your local machine.
5. DPI Display and Download
Once the DPI has been modified, the tool extracts the updated DPI values from the image and displays them on the screen. You can then download the modified image file directly to your device by clicking the "Download Converted Image" link. The downloaded image will include the new DPI settings in its metadata.
6. No Data Collection
The tool does not collect, store, or transmit any of your data. Everything is processed locally on your device, so you retain full control over your image files. This ensures that your privacy is protected and that your data remains secure.