在发送到服务器之前在 iPhone 中调整照片大小

发布于 2024-11-08 14:20:01 字数 164 浏览 0 评论 0原文

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

Making an app where we want to send a photo to a server along with some form data. The image is huge and it takes forever to upload and we really don't need the pixel information on the website. Is there any way to resize an image (from camera or your gallery) so that we're only sending a much smaller image into cyberspace? This is easy to do in Android but we're struggling to find an easy solution for iPhone.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ま柒月 2024-11-15 14:20:01

请参阅以正确的方式调整 UIImage 大小< /a> 用于调整代码大小和讨论。要选择图像,您可以执行以下操作

// 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];
}

See Resize a UIImage the right way for resizing code and discussion. To pick the image you can do

// 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];
}
中二柚 2024-11-15 14:20:01

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

The most of you question issues is covered by WWDC 2010 session N104. There is a scroll views, but methods, which described there can be using in you task.

尬尬 2024-11-15 14:20:01

在 UIImage 中:

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

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

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

In UIImage:

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

Just scratching out an idea...

UIImage smallerImage = [[ UIImage imageWithCGImage: biggerImage.CGImage scale: 0.1 orientation:  orient
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文