I had a similar issue, and gave up trying to rely on EXIF; instead I just interrogated the image myself:
if ($image->width() > $image->height()) {
$image->rotate(90);
}
Hi all,
For my project I need to upload images using an iPhone. This will be done in portrait mode, using a vue component which actually shows the image in portrait mode. The component creates a base64 version of the image which will be posted. So far so good.
On the Laravel side, this is a part of the function so far:
// Strip the first part of the base64 value.
$image = explode('.', $data['image']);
// Decode base64 value
$image = base64_decode($image[1], true);
// Make image with auto orientate
$image = Image::make($image)->orientate();
// Resize image
$image->resize(800, null, function ($constraint) {
$constraint->aspectRatio();
});
// Stream image
$image = $image->stream()->__toString();
// Save to S3.
Storage::disk('s3')->put($filename, $image, 'public');
Now the image actually gets uploaded to S3, but still in landscape mode, while take in portrait mode.
PHP is build using --enable-exif, using version 7.1.14
Anybody got an idea what to do next?
Please or to participate in this conversation.