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

  • Home
  • SEARCH
  • 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 6105373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:58:03+00:00 2026-05-23T13:58:03+00:00

I have an ImageManipulator class that performs some cropping, resizing and rotating of camera

  • 0

I have an “ImageManipulator” class that performs some cropping, resizing and rotating of camera images on the iPhone.

At the moment, everything works as expected but I keep getting a few huge spikes in memory consumption which occasionally cause the app to crash.

I have managed to isolate the problem to a part of the code where I check for the current image orientation property and rotate it accordingly to UIImageOrientationUp. I then get the image from the bitmap context and save it to disk.

This is currently what I am doing:

CGAffineTransform transform = CGAffineTransformIdentity;
// Check for orientation and set transform accordingly...
transform = CGAffineTransformTranslate(transform, self.size.width, 0);
transform = CGAffineTransformScale(transform, -1, 1);

// Create a bitmap context with the image that was passed so we can perform the rotation
CGContextRef ctx = CGBitmapContextCreate(NULL, self.size.width, self.size.height,
                                         CGImageGetBitsPerComponent(self.CGImage), 0,
                                         CGImageGetColorSpace(self.CGImage),
                                         CGImageGetBitmapInfo(self.CGImage));

// Rotate the context
CGContextConcatCTM(ctx, transform);

// Draw the image into the context
CGContextDrawImage(ctx, CGRectMake(0,0,self.size.height,self.size.width), self.CGImage);

// Grab the bitmap context and save it to the disk...

Even after trying to scale the image down to half or even 1/4 of the size, I am still seeing the spikes to I am wondering if there is a different / more efficient way to get the rotation done as above?

Thanks in advance for the replies.
Rog

  • 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-23T13:58:03+00:00Added an answer on May 23, 2026 at 1:58 pm

    If you are saving to JPEG, I guess an alternative approach is to save the image as-is and then set the rotation to whatever you’d like by manipulating the EXIF metadata? See for example this post. Simple but probably effective, even if you have to hold the image payload bytes in memory 😉

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

Sidebar

Related Questions

Have noticed issue while testing iphone app that if one quickly opens/dismisses a modal
Have a fun issue with sharepoint calendar view filtering. That code works fine: SPSecurity.RunWithElevatedPrivileges(delegate()
Have following setup: MainActivity class - extends activity MyLayout class - extends View Prefs
have a table that dynamically generates text boxes in run time. I want to
Have a build process that can't be edited and need to pack another war
Have a photography site that I want to prevent image copying from. How can
Have following Java code,that creates StringBuilder with \n,i.e. carriage return delimiters: while (scanner.hasNextLine()){ sb.append(scanner.nextLine()).append(\n);
Have an app that can use tts to read text messages. It can also
Have a flash player that pops out into a separate popup browser window. And
have been able to output images from BLOB, however I am now wanting to

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.