Menu

I Shipped HEIC Support. Then My iPhone Found 3 More Bugs.
📰

I Shipped HEIC Support. Then My iPhone Found 3 More Bugs.

DEV Community: ios·Chandan Singh·14 days ago
#XpKJ1PcW
#devtoios#devto#dev#tools#webp
Reading 0:00
15s threshold

I build editpdf.tools, free PDF and image tools that run in the browser. Users asked for iPhone HEIC support, so I added it. Then I tested everything on my own iPhone, and the phone had opinions.

Bug 1: "WebP" files the size of PNGs

I converted a photo to WebP on the iPhone. The file was as big as a PNG. Because it was a PNG. Safari does not support WebP in canvas.toBlob(), and instead of throwing, it hands back image/png. My code trusted the requested type and named it .webp.

Lesson: always check blob.type after toBlob(). I now fall back to a small browser WebP encoder that loads only when the native result is wrong.

Bug 2: rotated pages in the PDF

A form photo came out sideways in Image to PDF. The thumbnail looked fine. The PDF did not. Phone cameras save sideways pixels plus an EXIF orientation tag; browsers apply the tag, PDFs do not. I was embedding raw JPEG bytes.

Lesson: if you embed images into PDFs, read the EXIF orientation yourself and rotate on the page.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.