Iphone imagecopy旋转我的图像 [英] Iphone imagecopy rotates my image

查看:251
本文介绍了Iphone imagecopy旋转我的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个与ipad相机配合使用的HTML应用程序,并将拍摄的图像上传到我的服务器。
上传图片后,使用imagecopy()获取水印。

I'm building an HTML application that works with the ipad camera, and uploads the taken image to my server. When uploaded the image gets a watermark over it by using imagecopy().

当我在计算机上测试时,一切正常,但出于某种原因,如果我在ipad / ipod / iphone上以肖像拍照,带水印的图像会旋转到横向模式。

Everything works fine when I test it on my computer, but for some reason, if I take a picture on ipad/ipod/iphone in portrait, the image WITH the watermark gets rotated to a landscape mode.

澄清:原始图片是否正确上传,带有水印的图像旋转。当我在带有肖像图像的计算机上尝试时,这不会发生。

To clarify: the original picture is uploaded correctly, the image with the watermark is rotated. This does NOT happen when I try that on my computer with a portrait image.

这是一些代码,如果有帮助(我使用Codeigniter框架)。如果您需要更多代码,请问,虽然我认为上传本身没有任何问题。

Here is some code, if that helps (I use the Codeigniter framework). If you need any more code, just ask, although I don't think there's going anything wrong with the upload itself.

//The code for the imagecopy do add the watermark
$overlay = imagecreatefrompng(base_url() . 'assets/images/imgoverlay.png');
$img = imagecreatefromjpeg(base_url() . 'uploads/' . $config['file_name']);
$imageSize = getimagesize(base_url() . 'uploads/' . $config['file_name']);
$sx = imagesx($overlay);
$sy = imagesy($overlay);
$newWatermarkWidth = $imageSize[0];
$newWatermarkHeight = $sy * $newWatermarkWidth / $sx;

$test = imagecopy(
          $img, 
          $overlay, 
          $imageSize[0]/2 - $newWatermarkWidth/2,
          $imageSize[1] - $newWatermarkHeight,
          0,
          0,
          imagesx($img),imagesy($img)
        );

非常感谢!

推荐答案

我猜这与这个问题有关:生成的图片显示翻转

I'd guess this is related to this question: Generated images showing flipped

iPad相机可能只是以相同的方式存储图像,无论设备方向如何,而是写一个Exif标签以确保它在显示时正确旋转。

The iPad camera probably just stores the image in the same way, regardless of device orientation, and instead writes an Exif tag to make sure it's properly rotated when displayed.

这篇关于Iphone imagecopy旋转我的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆