Small programs and mobile image uploading

Original link: https://dorole.com/2206/

Image uploading is a common requirement in various program development. Due to the professional and mature file management on the PC side, an <input file> can be done directly, but on the mobile side, it becomes complicated. Mainly speaking: the first is that the format increases, and the compatibility is difficult to guarantee. Each manufacturer has its own conversion ideas. The second is to simply erase EXIF ​​out of privacy protection. When doing this, Instant Album is constantly exploring and moving forward, and has been cheated several times.

For the photo album program, what we need is the “complete” “original image”, which has two meanings. The first is to include complete EXIF ​​information, so as to draw a shared image with the camera model and shooting parameters, and the second is to include the complete EXIF ​​information. The original image without format conversion and in-camera post-production, save the original data as much as possible, of course, this is the second influence.

Instant Album is an album mainly based on WeChat applet. Naturally, the first upload function provided by WeChat official is used, namely wx.chooseImage() and wx.chooseMedia() Unfortunately, neither of them can meet the requirements. , EXIF ​​was erased, converted into JPG, the video was compressed by WeChat, and the image quality was unacceptable.

Later, the embedded webview was used to upload through the H5 page, so that the right to choose the file was completely determined by the mobile phone system. In the subsequent test, it was found that in the iOS system, the camera shooting format selected “efficient”, that is, HEIF Format, it will still be converted to JPEG when uploading, and EXIF ​​will be erased, but the ProRAW format can retain EXIF ​​when automatically converting JPEG, the shooting format selects “Best Compatibility”, and EXIF ​​can also be retained, which is really fascinating. operate.

(iOS seems to have a bug in the process of automatic conversion. The width and height pixels are not changed during the process of converting the direction 6 to 1, resulting in the wrong aspect ratio. If you choose large, medium, and small in the selection photo, the direction will be lost, and the vertical photo will be taken. display horizontally)

Since it is a webview, I also thought about whether to get EXIF ​​in advance through JavaScript, so I used exif-reader.js to read EXIF. Unfortunately, the test results are consistent with the above performance. It’s easy to understand, because at the moment of selecting the file, a temporary JPEG has been converted, and the developer side cannot perceive this process.

Another interesting thing is that the HEIF image is saved to “File” by sharing on the mobile phone, and then select “Select File” on the upload page to find the file just now, it is possible to upload the original HEIC format file and retain the complete EXIF.

To sum up, Instant Album also provides a PC-side upload method to avoid these “restrictions”. Maybe it’s time to develop a native app?

This article is reprinted from: https://dorole.com/2206/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment