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().
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.
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)
);
Many thanks!