【问题标题】:resizing a photo in iPhone before sending to a server在发送到服务器之前在 iPhone 中调整照片大小
【发布时间】:2011-05-18 20:26:21
【问题描述】:

制作一个我们想要将照片连同一些表单数据发送到服务器的应用。图片很大,上传需要很长时间,我们真的不需要网站上的像素信息。有什么方法可以调整图像的大小(来自相机或您的画廊),以便我们只将更小的图像发送到网络空间?这在 Android 中很容易做到,但我们正在努力为 iPhone 找到一个简单的解决方案。

【问题讨论】:

    标签: iphone resize photo crop autoresize


    【解决方案1】:

    请参阅Resize a UIImage the right way 调整代码大小和讨论。要选择图像,您可以这样做

    // select image
    UIImagePickerController *picker = [UIImagePickerController new];
    picker.delegate = self;
    picker.allowsEditing = YES;
    [yourViewController presentModalViewController:picker];
    
    // delegate method
    - (void) imagePickerController:(UIImagePickerController *)picker 
     didFinishPickingMediaWithInfo:(NSDictionary *)info {
        UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
    }
    

    【讨论】:

    • +1 表示“以正确的方式调整 UIImage 的大小”。这是一个真正的图像大小调整教程,包含(优秀的)代码以供使用。
    【解决方案2】:

    WWDC 2010 会议 N104 涵盖了大多数问题。有一个滚动视图,但是描述的方法可以在你的任务中使用。

    【讨论】:

      【解决方案3】:

      在 UIImage 中:

       + (UIImage *)imageWithCGImage:(CGImageRef)imageRef scale:(CGFloat)scale orientation:(UIImageOrientation)orientation
      

      只是想出一个想法......

      UIImage smallerImage = [[ UIImage imageWithCGImage: biggerImage.CGImage scale: 0.1 orientation:  orient
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-08-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-07-24
        • 2012-10-12
        • 2019-04-04
        相关资源
        最近更新 更多