Menu

Stitching Photos into One Long Image in Swift: Common Width, a Height Cap, and One Photo in Memory at a Time
📰

Stitching Photos into One Long Image in Swift: Common Width, a Height Cap, and One Photo in Memory at a Time

DEV Community: swift·Maxwell·2 days ago
#YEOwXLKh
#devtoswift#devto#dev#plan#height
Reading 0:00
15s threshold

A long image is the simplest way to post a set of photos as one thing: a trip, a recipe, a product from every angle. Stack the photos top to bottom, export one file, done. The first version most of us write is also simple: load every photo as a UIImage , add up the heights, draw them into a UIGraphicsImageRenderer , save.

It works on the simulator with five screenshots. Then someone picks twelve 48-megapixel photos, two of them shot sideways, and the app either dies or produces a 9,000 × 60,000 pixel file that no social app will show at full size.

I build BatchMark, an on-device photo app for iPhone, and its Photo Stories feature joins a set of finished photos into one long image. This post is a teaching extract of the problems you hit when you build that kind of stitcher, not the app's source.…

Continue reading — create a free account

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