Reputation: 10408
Since the adjustment data used when saving a PHAsset
can be completely user-defined, are there any memory size limitations for it?
For instance, can I store something like masks or layers (so basically multiple bitmaps) in it?
Upvotes: 0
Views: 358
Reputation: 126167
The documentation for PHAdjustmentData.init
notes (emphasis mine):
Because Photos limits the size of adjustment data, you should keep your edit information short and descriptive. Don’t use image data to describe an edit—instead, save only the minimal information that is needed to recreate the edit.
Your app must provide a non-empty NSData object for the data parameter. If you cannot provide relevant data to describe an edit, you may pass data that encodes an NSUUID object.
In other words, adjustment data isn't for Photoshop-style files that encode an edit in terms of the actual new pixels. Remember, the main idea for adjustment data is that you can use it to revert, reconstruct, and alter whatever work was performed in the last user edit.
Adjustment data is most commonly used for saying things like "blur filter @ 20px + darken by 20% + crop to (100,100,300,400)". For more complicated edits, you'll have to get more creative — for example, for an effect that the user paints on with a brush, you can probably record the brush strokes (plus brush radius and any other parameters) in a lot less data than you'd use to store bitmaps.
And failing all that, if you have edits that can only be described using data too large to fit into adjustment data, notice that tip Apple left about using a UUID — you can store your data externally to Photos, and use adjustment data to store a key that lets you look up an edit in your external storage. (Of course, you'll then have to make sure that your external storage is in all the places that iCloud Photo Library syncs to, and have a way to fall back gracefully if you can't access it, etc...)
Oh, and as for what the upper limit is... it's possible that Apple doesn't publish the limit because it might be subject to change across devices, iCloud account status, OS versions, or some other factor. So even if you've found a limit experimentally, it might not always hold true.
Upvotes: 1
Reputation: 10408
I did a few tests and it seems 2 MB is the answer. It would be good to have an official statement, though...
Upvotes: 0