Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7059837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:16:48+00:00 2026-05-28T04:16:48+00:00

I am currently using the following code to get an UIImage from an ALAsset

  • 0

I am currently using the following code to get an UIImage from an ALAsset in an iOS app.

ALAssetRepresentation *rep = [self.asset defaultRepresentation];
CGImageRef ref = [rep fullResolutionImage];
ALAssetOrientation orientation = [[self.asset valueForProperty:@"ALAssetPropertyOrientation"] intValue];
UIImage *image = [UIImage imageWithCGImage:ref scale:1.0 orientation:(UIImageOrientation)orientation];

This works very well as long as the image is reasonably small (e.g. taken with the device’s camera). However if the image is too large (6000px^2 and more), the app will run out of memory during this step:

CGImageRef ref = [rep fullResolutionImage];

I would like to detect this condition before the app crashes or (ideally) set a maximum size for the returned image.

I am aware that fullScreenImage will return a smaller image, however the app requires a much higher resolution from the image for zooming.

Furthermore, using the byte size of the asset is unreliable as highly compressed formats such as JPG may well be small in packed size but still consume too much memory if their size in pixels is high (low detail images, highly compressed images).

Any input on how to either get the dimensions of the image and detect this situation beforehand so I can cancel loading and display an error or how to get a smaller version of such a large asset would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:16:49+00:00Added an answer on May 28, 2026 at 4:16 am

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I using the following code to get my JSON output from MySQL. <?php
I'm currently using the following PHP code: // Get all subordinates $subords = array();
In short, currently I am using the following code to pull records from multiple
I'm currently using the following simple code to insert content into TinyMCE's editor: tinyMCE.get(ole_mce).execCommand(mceInsertContent,false,'hello
Currently for my blog I get a list of years/dates using the following code:
I am currently using the following code to get the current row and column
Currently i'm using the following code to get my custom MembershipUser, with my custom
I am currently using the following code to create a web request: Dim myRequest
I'm currently using the following code to append a X link to each element
I'm currently using the following code (C#): private static void PlayLoop(string filename) { Audio

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.