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 7734397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:14:21+00:00 2026-06-01T07:14:21+00:00

I have this code, which creates an image, and then adds some effects to

  • 0

I have this code, which creates an image, and then adds some effects to it and sizes it down to make largeThumbnail.

UIImage *originalImage = [UIImage imageWithData:self.originalImage];
thumbnail = createLargeThumbnailFromImage(originalImage);

NSLog(@"thumbnail: %f", thumbnail.size.height);
NSData *thumbnailData = UIImageJPEGRepresentation(thumbnail, 1.0);

Later on:

UIImage *image = [UIImage imageWithData:self.largeThumbnail];
NSLog(@"thumbnail 2: %f", image.size.height);

NSLog returns:

thumbnail: 289.000000
thumbnail 2: 578.000000

As you can see, when it converts the image back from data, it makes it 2x the size. Any ideas why this may be happening?

Large thumbnail code:

UIImage *createLargeThumbnailFromImage(UIImage *image) {
    UIImage *resizedImage;

        resizedImage = [image imageScaledToFitSize:LARGE_THUMBNAIL_SIZE];

    CGRect largeThumbnailRect = CGRectMake(0, 0, resizedImage.size.width, resizedImage.size.height);

    UIGraphicsBeginImageContextWithOptions(resizedImage.size, NO, 0);
    CGContextRef context = UIGraphicsGetCurrentContext();

    //Image
    CGContextTranslateCTM(context, 0, resizedImage.size.height);
    CGContextScaleCTM(context, 1.0, -1.0);
    CGContextDrawImage(context, largeThumbnailRect, resizedImage.CGImage);

    //Border
    CGContextSaveGState(context);
    CGRect innerRect = rectForRectWithInset(largeThumbnailRect, 1.5);
    CGMutablePathRef borderPath = createRoundedRectForRect(innerRect, 0);
    CGContextSetStrokeColorWithColor(context, [[UIColor whiteColor] CGColor]);
    CGContextSetLineWidth(context, 3);
    CGContextAddPath(context, borderPath);
    CGContextStrokePath(context);
    CGContextRestoreGState(context);

    UIImage *thumbnail = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return thumbnail;
}
  • 1 1 Answer
  • 1 View
  • 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-06-01T07:14:22+00:00Added an answer on June 1, 2026 at 7:14 am

    Try replacing the part where you load the second image:

    UIImage *image = [UIImage imageWithData:self.largeThumbnail];
    

    with this one:

    UIImage *jpegImage = [UIImage imageWithData:self.largeThumbnail];
    UIImage *image = [UIImage imageWithCGImage:jpegImage.CGImage scale:originalImage.scale orientation:jpegImage.imageOrientation];
    

    What happens here is that the image scale is not set, so you get double image dimensions.

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

Sidebar

Related Questions

I have this code which should create a splash image with either no animation
I have this code which can display drop down in div tag of html.
This is a bit maddening. I have code which saves the current background-image from
I have this code that lets me create a custom UIBarButton which is inside
I have this code which is called at an onChange event of an function
I have this code which gets WP posts, but it gets all the posts
I have this code (which is way simplified from the real code): public interface
I have this code which compiles and works as expected: class Right {}; class
I have this code which will include template.php file from inside each of these
I have this code which is passed to Paypal checkout: <?php foreach ($paypalBasket as

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.