0

i am creating app using facebook. if i am trying to upload photo to facebook means i got following message any give idea for solve that

"The provided user_generated photo for an OG action must be at least 480px in both dimensions"

Mahe
  • 98
  • 1
  • 8
  • You don't want to just use one of the techniques to enlarge and image, because that will pixelate and be degraded in the process. (And if FB thought it was ok to pixelate the image, they would have done that themselves.) The question is how to fix the your workflow that generated the image so that it generates one that is at least 480px in both dimensions. Describe how you're generating the image that you're uploading to Facebook. – Rob Dec 10 '13 at 13:21
  • i am uploading image from photo library@Rob – Mahe Dec 10 '13 at 13:44
  • You should show us your code for picking a photo from the library. Most photos in your library will be more than 480px but it's possible to have ones that are smaller (screen snapshot on non-retina device, photos saved from apps, etc.). If you manually created image in library from screen snapshot (e.g. via `renderInContext`), then make sure you use `UIGraphicsBeginImageContextWithOptions` with scale of `0`. – Rob Dec 10 '13 at 14:59

3 Answers3

2

I use a function like follow to get an image with any size. Original image should big than you wanted.(ps:You can try an image little)

+ (UIImage *)thumbnailWithImageWithoutScale:(UIImage *)image size:(CGSize)wantSize
{
    UIImage * targetImage;
    if (nil == image) {
        targetImage = nil;
    }else{
        CGSize size = image.size;
        CGRect rect;
        if (wantSize.width/wantSize.height > size.width/size.height) {
            rect.size.width = wantSize.height*size.width/size.height;
            rect.size.height = wantSize.height;
            rect.origin.x = (wantSize.width - rect.size.width)/2;
            rect.origin.y = 0;
        } else{
            rect.size.width = wantSize.width;
            rect.size.height = wantSize.width*size.height/size.width;
            rect.origin.x = 0;
            rect.origin.y = (wantSize.height - rect.size.height)/2;
        }
        UIGraphicsBeginImageContext(wantSize);
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextSetFillColorWithColor(context, [[UIColor clearColor] CGColor]);
        UIRectFill(CGRectMake(0, 0, wantSize.width, wantSize.height));//clear background
        [image drawInRect:rect];
        targetImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
    }
    return targetImage;
}
Dracuuula
  • 313
  • 2
  • 15
0

You must provide a bigger image, with at least 480px width and height.

João Mosmann
  • 2,884
  • 19
  • 25
0

Your image is apparently smaller than 480px wide or tall. The problem is either that the original image is too small, or you're retrieving it incorrectly. You could, theoretically resize the image to make it bigger, but that will result in pixelation that is probably undesirable.

You should show us how you're retrieving the image. For example, when I want to pick a photo from my library, I'll use the code adapted from Picking an Item from the Photo Library from the Camera Programming Topics for iOS:

UIImagePickerController *mediaUI = [[UIImagePickerController alloc] init];
mediaUI.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

// To instead show the controls to allow user to trim image, set this to YES;
// If no cropping available, set this to NO.

mediaUI.allowsEditing = YES;

mediaUI.delegate = delegate;

And then, you obviously have to implement the didFinishPickingMediaWithInfo:

#pragma mark - UIImagePickerControllerDelegate

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
    UIImage *originalImage, *editedImage, *imageToUse;

    // Handle a still image picked from a photo album
    if (CFStringCompare ((CFStringRef) mediaType, kUTTypeImage, 0) == kCFCompareEqualTo) {

        editedImage = (UIImage *) [info objectForKey:UIImagePickerControllerEditedImage];
        originalImage = (UIImage *) [info objectForKey:UIImagePickerControllerOriginalImage];

        if (editedImage) {
            imageToUse = editedImage;
        } else {
            imageToUse = originalImage;
        }

        NSLog(@"image size = %@", NSStringFromCGSize(imageToUse.size));

        if (imageToUse.size.width < 480 || imageToUse.size.height < 480)
        {
                [[[UIAlertView alloc] initWithTitle:nil
                                            message:@"Please select image that is at least 480 x 480"
                                           delegate:nil
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil] show];
        }
        else
        {
            // do something with imageToUse
        }
    }

    [picker dismissViewControllerAnimated: YES completion:nil];
}
Rob
  • 415,655
  • 72
  • 787
  • 1,044