Set Maximum Size for CGImageRef from ALAssetRepresentation

本秂侑毒 提交于 2019-12-05 21:21:45

UPDATE:

After some discussion in the comments.

You can obtain the files/asset's Exif info with the call

[asset metadata]

The reference I found is here sarofox.alasset-image-metadata The page also shows how to get individual properties. This should allow you to get the pixel sizes before you open the file/asset.

MY OLD ANSWER:

is below, in case any one finds the idea helpful.:

This is only a guess. But could you not use ALAssetRepresentation getBytes:fromOffset:length:error:

Using byte sizes that you would expect a device camera's image would be.

Run a check with a fromOffset from the start of the file size of the file. And a length to the ( wanted maximum ) end of the file size.

Read the size in the buffer. If it is smaller than the request then you are ok. If it is exactly the same as the range requested then there may be more left in the file (It maybe bigger.)

If so, Run a new request of getBytes:fromOffset:length:error:* this time with a fromOffset from the length of the last request and new length.

You can then add the results up and determine if the whole file will be too large.

But never have a buffer/file that is too large

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!