php resizing image on upload rotates the image when i don't want it to

后端 未结 3 689
日久生厌
日久生厌 2020-12-15 01:20

I Have an upload script that resizes the images uploaded, however, some images are being saved as a rotated image when i dont want them to, any way to preserve the original

3条回答
  •  旧时难觅i
    2020-12-15 02:00

    The EXIF data is probably being ignored by this basic script.

    Investigate whether your images have embedded rotation information using exif_read_data, and then auto-correct the rotation with a function like this.

    In your case,

    1. take the script I just linked,
    2. paste it above the first line of your code,
    3. change all the $image-> bits to $resizeObj->
      (vim-style grep: %s/image->/resizeObj->/g)

提交回复
热议问题