What resources, such as the PHP manual and online tutorials, can be helpful for resolving image orientation issues in PHP?

When uploading images in PHP, it's common to encounter orientation issues where the image appears rotated incorrectly. This can be due to EXIF data stored in the image file. To resolve this issue, you can use PHP libraries like Imagick or GD to read the EXIF data and rotate the image accordingly.

// Example code using Imagick to fix image orientation issue
$image = new Imagick('path/to/image.jpg');
$orientation = $image->getImageOrientation();

switch ($orientation) {
    case Imagick::ORIENTATION_TOPRIGHT:
        $image->rotateImage('white', 90);
        break;
    case Imagick::ORIENTATION_BOTTOMRIGHT:
        $image->rotateImage('white', 180);
        break;
    case Imagick::ORIENTATION_BOTTOMLEFT:
        $image->rotateImage('white', 270);
        break;
}

$image->setImageOrientation(Imagick::ORIENTATION_TOPLEFT);
$image->writeImage('path/to/fixed_image.jpg');