Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2022-02-25 11:40:01

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,702
Website

Thumbnail creation can result in rotated / upside-down images

(split off from this smd_thumbnail thread)

A couple of clients have recently reported that images uploaded to Textpattern appear rotated or upside down. Initially I thought this was smd_thumbnail as the display looked fine in com_article_image in the write panel sidebar but the display on the page was wrong where I was using smd_thumbnail to create srcsets.

After testing one of these images on a brand new txp 4.8.8 PHP 8.1 local installation, I can confirm it happens with thumbnail creation in the core. The main image has the correct orientation, the thumbnail created is upside down –exhaustive details on the image below:

Observed in the following site contexts:

localhost:     txp 4.8.8, PHP 8.1.3,  GD version 2.3.3, Supported EXIF Version: 0220
online server: txp 4.8.8, PHP 8.1.3,  GD version 2.2.5, Supported EXIF Version: 0220 (Lightspeed 8.0)
online server: txp 4.9-d, PHP 8.0.16, GD version 2.2.5, Supported EXIF Version: 0220 (Lightspeed 7.9)

In this particular image, the EXIF information shows orientation as Rotate 180.

This is the output for this image of exiftoolOrientation: Rotate 180:

ExifTool Version Number         : 12.30
File Name                       : 2449.jpg
Directory                       : /Users/julian/Desktop
File Size                       : 2.6 MiB
File Modification Date/Time     : 2022:02:25 12:09:57+01:00
File Access Date/Time           : 2022:02:25 12:14:31+01:00
File Inode Change Date/Time     : 2022:02:25 12:11:49+01:00
File Permissions                : -rw-r--r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
Exif Byte Order                 : Big-endian (Motorola, MM)
Make                            : Apple
Camera Model Name               : iPhone SE (2nd generation)
Orientation                     : Rotate 180
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Software                        : 15.2.1
Modify Date                     : 2022:02:24 19:18:43
Host Computer                   : iPhone SE (2nd generation)
Y Cb Cr Positioning             : Centered
Exposure Time                   : 1/100
F Number                        : 1.8
Exposure Program                : Program AE
ISO                             : 64
Exif Version                    : 0232
Date/Time Original              : 2022:02:24 19:18:43
Create Date                     : 2022:02:24 19:18:43
Components Configuration        : Y, Cb, Cr, -
Shutter Speed Value             : 1/100
Aperture Value                  : 1.8
Brightness Value                : 4.783037509
Exposure Compensation           : 0
Metering Mode                   : Multi-segment
Flash                           : Off, Did not fire
Focal Length                    : 4.0 mm
Subject Area                    : 2013 1511 2217 1330
Run Time Flags                  : Valid
Run Time Value                  : 202663539324958
Run Time Scale                  : 1000000000
Run Time Epoch                  : 0
Acceleration Vector             : 1.007881523 0.01814972982 -0.02786204592
Sub Sec Time Original           : 299
Sub Sec Time Digitized          : 299
Flashpix Version                : 0100
Color Space                     : Uncalibrated
Exif Image Width                : 4032
Exif Image Height               : 3024
Sensing Method                  : One-chip color area
Scene Type                      : Directly photographed
Exposure Mode                   : Auto
White Balance                   : Auto
Focal Length In 35mm Format     : 28 mm
Scene Capture Type              : Standard
Lens Info                       : 3.99000001mm f/1.8
Lens Make                       : Apple
Lens Model                      : iPhone SE (2nd generation) back camera 3.99mm f/1.8
Composite Image                 : General Composite Image
Compression                     : JPEG (old-style)
Thumbnail Offset                : 2274
Thumbnail Length                : 6219
Profile CMM Type                : Apple Computer Inc.
Profile Version                 : 4.0.0
Profile Class                   : Display Device Profile
Color Space Data                : RGB
Profile Connection Space        : XYZ
Profile Date Time               : 2017:07:07 13:22:32
Profile File Signature          : acsp
Primary Platform                : Apple Computer Inc.
CMM Flags                       : Not Embedded, Independent
Device Manufacturer             : Apple Computer Inc.
Device Model                    : 
Device Attributes               : Reflective, Glossy, Positive, Color
Rendering Intent                : Perceptual
Connection Space Illuminant     : 0.9642 1 0.82491
Profile Creator                 : Apple Computer Inc.
Profile ID                      : ca1a9582257f104d389913d5d1ea1582
Profile Description             : Display P3
Profile Copyright               : Copyright Apple Inc., 2017
Media White Point               : 0.95045 1 1.08905
Red Matrix Column               : 0.51512 0.2412 -0.00105
Green Matrix Column             : 0.29198 0.69225 0.04189
Blue Matrix Column              : 0.1571 0.06657 0.78407
Red Tone Reproduction Curve     : (Binary data 32 bytes, use -b option to extract)
Chromatic Adaptation            : 1.04788 0.02292 -0.0502 0.02959 0.99048 -0.01706 -0.00923 0.01508 0.75168
Blue Tone Reproduction Curve    : (Binary data 32 bytes, use -b option to extract)
Green Tone Reproduction Curve   : (Binary data 32 bytes, use -b option to extract)
Image Width                     : 4032
Image Height                    : 3024
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Run Time Since Power Up         : 2 days 8:17:44
Aperture                        : 1.8
Image Size                      : 4032x3024
Megapixels                      : 12.2
Scale Factor To 35 mm Equivalent: 7.0
Shutter Speed                   : 1/100
Create Date                     : 2022:02:24 19:18:43.299
Date/Time Original              : 2022:02:24 19:18:43.299
Thumbnail Image                 : (Binary data 6219 bytes, use -b option to extract)
Circle Of Confusion             : 0.004 mm
Field Of View                   : 65.5 deg
Focal Length                    : 4.0 mm (35 mm equivalent: 28.0 mm)
Hyperfocal Distance             : 2.07 m
Light Value                     : 9.0
Lens ID                         : iPhone SE (2nd generation) back camera 3.99mm f/1.8

and of mdlskMDItemOrientation = 0:

_kMDItemDisplayNameWithExtensions      = "2449.jpg"
kMDItemAcquisitionMake                 = "Apple"
kMDItemAcquisitionModel                = "iPhone SE (2nd generation)"
kMDItemAperture                        = 1.69599381283836
kMDItemBitsPerSample                   = 24
kMDItemColorSpace                      = "RGB"
kMDItemContentCreationDate             = 2022-02-24 18:18:43 +0000
kMDItemContentCreationDate_Ranking     = 2022-02-24 00:00:00 +0000
kMDItemContentModificationDate         = 2022-02-24 18:18:43 +0000
kMDItemContentModificationDate_Ranking = 2022-02-24 00:00:00 +0000
kMDItemContentType                     = "public.jpeg"
kMDItemContentTypeTree                 = (
    "public.jpeg",
    "public.image",
    "public.data",
    "public.item",
    "public.content"
)
kMDItemCreator                         = "15.2.1"
kMDItemDateAdded                       = 2022-02-25 11:09:57 +0000
kMDItemDateAdded_Ranking               = 2022-02-25 00:00:00 +0000
kMDItemDisplayName                     = "2449.jpg"
kMDItemDocumentIdentifier              = 0
kMDItemDownloadedDate                  = (
    "2022-02-25 11:09:57 +0000"
)
kMDItemEXIFVersion                     = "2.3.2"
kMDItemExposureMode                    = 0
kMDItemExposureProgram                 = 2
kMDItemExposureTimeSeconds             = 0.01
kMDItemFlashOnOff                      = 0
kMDItemFNumber                         = 1.8
kMDItemFocalLength                     = 3.99
kMDItemFocalLength35mm                 = 28
kMDItemFSContentChangeDate             = 2022-02-25 11:09:57 +0000
kMDItemFSCreationDate                  = 2022-02-25 11:09:57 +0000
kMDItemFSCreatorCode                   = ""
kMDItemFSFinderFlags                   = 0
kMDItemFSHasCustomIcon                 = (null)
kMDItemFSInvisible                     = 0
kMDItemFSIsExtensionHidden             = 0
kMDItemFSIsStationery                  = (null)
kMDItemFSLabel                         = 0
kMDItemFSName                          = "2449.jpg"
kMDItemFSNodeCount                     = (null)
kMDItemFSOwnerGroupID                  = 20
kMDItemFSOwnerUserID                   = 501
kMDItemFSSize                          = 2754240
kMDItemFSTypeCode                      = ""
kMDItemHasAlphaChannel                 = 0
kMDItemInterestingDate_Ranking         = 2022-02-25 00:00:00 +0000
kMDItemISOSpeed                        = 64
kMDItemKind                            = "JPEG-Bild"
kMDItemLastUsedDate                    = 2022-02-25 11:11:49 +0000
kMDItemLastUsedDate_Ranking            = 2022-02-25 00:00:00 +0000
kMDItemLogicalSize                     = 2754240
kMDItemMeteringMode                    = 5
kMDItemOrientation                     = 0
kMDItemPhysicalSize                    = 2756608
kMDItemPixelCount                      = 12192768
kMDItemPixelHeight                     = 3024
kMDItemPixelWidth                      = 4032
kMDItemProfileName                     = "Display P3"
kMDItemRedEyeOnOff                     = 0
kMDItemResolutionHeightDPI             = 72
kMDItemResolutionWidthDPI              = 72
kMDItemUseCount                        = 5
kMDItemUsedDates                       = (
    "2022-02-24 23:00:00 +0000"
)
kMDItemWhereFroms                      = (
    "https://domain.com/images/2449.jpg?1645781673"
)
kMDItemWhiteBalance                    = 0

and of identify -verboseOrientation: BottomRight.

Image:
  Filename: /Users/julian/Desktop/2449.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 4032x3024+0+0
  Resolution: 72x72
  Print size: 56x42
  Units: PixelsPerInch
  Colorspace: sRGB
  Type: TrueColor
  Base type: Undefined
  Endianness: Undefined
  Depth: 8-bit
  Channel depth:
    Red: 8-bit
    Green: 8-bit
    Blue: 8-bit
  Channel statistics:
    Pixels: 12192768
    Red:
      min: 0  (0)
      max: 255 (1)
      mean: 166.7 (0.653726)
      median: 211 (0.827451)
      standard deviation: 43.8538 (0.171976)
      kurtosis: 0.0766166
      skewness: -0.614242
      entropy: 0.887777
    Green:
      min: 0  (0)
      max: 255 (1)
      mean: 166.527 (0.653047)
      median: 199 (0.780392)
      standard deviation: 39.578 (0.155208)
      kurtosis: 1.956
      skewness: -1.21061
      entropy: 0.882067
    Blue:
      min: 0  (0)
      max: 255 (1)
      mean: 161.819 (0.634583)
      median: 185 (0.72549)
      standard deviation: 37.9978 (0.149011)
      kurtosis: 3.01997
      skewness: -1.66286
      entropy: 0.849631
  Image statistics:
    Overall:
      min: 0  (0)
      max: 255 (1)
      mean: 165.015 (0.647119)
      median: 198.333 (0.777778)
      standard deviation: 40.4765 (0.158732)
      kurtosis: 1.48286
      skewness: -1.07034
      entropy: 0.873158
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Matte color: grey74
  Background color: white
  Border color: srgb(223,223,223)
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 4032x3024+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 94
  Orientation: BottomRight
  Profiles:
    Profile-exif: 8489 bytes
    Profile-icc: 548 bytes
  Properties:
    date:create: 2022-02-25T11:11:49+00:00
    date:modify: 2022-02-25T11:09:57+00:00
    exif:ApertureValue: 54823/32325
    exif:BrightnessValue: 283218/59213
    exif:ColorSpace: 65535
    exif:ComponentsConfiguration: 1, 2, 3, 0
    exif:DateTime: 2022:02:24 19:18:43
    exif:DateTimeDigitized: 2022:02:24 19:18:43
    exif:DateTimeOriginal: 2022:02:24 19:18:43
    exif:ExifOffset: 252
    exif:ExifVersion: 48, 50, 51, 50
    exif:ExposureBiasValue: 0/1
    exif:ExposureMode: 0
    exif:ExposureProgram: 2
    exif:ExposureTime: 1/100
    exif:Flash: 16
    exif:FlashPixVersion: 48, 49, 48, 48
    exif:FNumber: 9/5
    exif:FocalLength: 399/100
    exif:FocalLengthIn35mmFilm: 28
    exif:LensMake: Apple
    exif:LensModel: iPhone SE (2nd generation) back camera 3.99mm f/1.8
    exif:LensSpecification: 4183519/1048501, 4183519/1048501, 9/5, 9/5
    exif:Make: Apple
    exif:MakerNote: 65, 112, 112, 108, 101, 32, 105, 79, 83, 0, 0, 1, 77, 77, 0, 35, 0, 1, 0, 9, 0, 0, 0, 1, 0, 0, 0, 14, 0, 2, 0, 7, 0, 0, 2, 46, 0, 0, 1, 184, 0, 3, 0, 7, 0, 0, 0, 104, 0, 0, 3, 230, 0, 4, 0, 9, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, 0, 9, 0, 0, 0, 1, 0, 0, 0, 199, 0, 6, 0, 9, 0, 0, 0, 1, 0, 0, 0, 202, 0, 7, 0, 9, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, 0, 10, 0, 0, 0, 3, 0, 0, 4, 78, 0, 12, 0, 10, 0, 0, 0, 2, 0, 0, 4, 102, 0, 13, 0, 9, 0, 0, 0, 1, 0, 0, 0, 5, 0, 14, 0, 9, 0, 0, 0, 1, 0, 0, 0, 4, 0, 16, 0, 9, 0, 0, 0, 1, 0, 0, 0, 1, 0, 20, 0, 9, 0, 0, 0, 1, 0, 0, 0, 10, 0, 22, 0, 2, 0, 0, 0, 29, 0, 0, 4, 118, 0, 23, 0, 9, 0, 0, 0, 1, 34, 80, 32, 0, 0, 25, 0, 9, 0, 0, 0, 1, 0, 0, 0, 2, 0, 26, 0, 2, 0, 0, 0, 6, 0, 0, 4, 148, 0, 31, 0, 9, 0, 0, 0, 1, 0, 0, 0, 0, 0, 32, 0, 2, 0, 0, 0, 37, 0, 0, 4, 154, 0, 33, 0, 10, 0, 0, 0, 1, 0, 0, 4, 192, 0, 35, 0, 9, 0, 0, 0, 2, 0, 0, 4, 200, 0, 37, 0, 9, 0, 0, 0, 1, 0, 0, 0, 138, 0, 38, 0, 9, 0, 0, 0, 1, 0, 0, 0, 3, 0, 39, 0, 10, 0, 0, 0, 1, 0, 0, 4, 208, 0, 40, 0, 9, 0, 0, 0, 1, 0, 0, 0, 1, 0, 43, 0, 2, 0, 0, 0, 37, 0, 0, 4, 216, 0, 45, 0, 9, 0, 0, 0, 1, 0, 0, 23, 164, 0, 46, 0, 9, 0, 0, 0, 1, 0, 0, 0, 6, 0, 47, 0, 9, 0, 0, 0, 1, 0, 0, 0, 96, 0, 54, 0, 9, 0, 0, 0, 1, 0, 0, 8, 136, 0, 55, 0, 9, 0, 0, 0, 1, 0, 0, 0, 4, 0, 59, 0, 9, 0, 0, 0, 1, 0, 0, 0, 0, 0, 60, 0, 9, 0, 0, 0, 1, 0, 0, 0, 4, 0, 65, 0, 7, 0, 0, 0, 42, 0, 0, 4, 254, 0, 74, 0, 9, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 98, 112, 108, 105, 115, 116, 48, 48, 79, 17, 2, 0, 153, 0, 107, 0, 165, 0, 147, 0, 125, 0, 107, 0, 90, 0, 111, 0, 135, 0, 151, 0, 182, 0, 223, 0, 229, 0, 231, 0, 222, 0, 208, 0, 164, 0, 115, 0, 172, 0, 149, 0, 114, 0, 162, 0, 173, 0, 142, 0, 116, 0, 129, 0, 150, 0, 160, 0, 200, 0, 230, 0, 225, 0, 213, 0, 180, 0, 127, 0, 191, 0, 184, 0, 164, 0, 166, 0, 196, 0, 200, 0, 204, 0, 156, 0, 122, 0, 135, 0, 153, 0, 178, 0, 219, 0, 222, 0, 198, 0, 141, 0, 213, 0, 212, 0, 207, 0, 186, 0, 227, 0, 222, 0, 225, 0, 211, 0, 196, 0, 170, 0, 133, 0, 141, 0, 161, 0, 199, 0, 212, 0, 155, 0, 232, 0, 232, 0, 235, 0, 241, 0, 236, 0, 230, 0, 236, 0, 223, 0, 219, 0, 223, 0, 203, 0, 152, 0, 135, 0, 150, 0, 218, 0, 158, 0, 239, 0, 241, 0, 228, 0, 215, 0, 241, 0, 244, 0, 240, 0, 228, 0, 222, 0, 221, 0, 176, 0, 156, 0, 161, 0, 102, 0, 220, 0, 161, 0, 232, 0, 220, 0, 175, 0, 210, 0, 241, 0, 2, 1, 254, 0, 244, 0, 235, 0, 230, 0, 194, 0, 163, 0, 149, 0, 92, 0, 229, 0, 139, 0, 119, 0, 104, 0, 156, 0, 241, 0, 252, 0, 245, 0, 249, 0, 206, 0, 243, 0, 242, 0, 188, 0, 159, 0, 142, 0, 112, 0, 235, 0, 149, 0, 189, 0, 179, 0, 156, 0, 207, 0, 222, 0, 206, 0, 202, 0, 212, 0, 201, 0, 207, 0, 144, 0, 169, 0, 155, 0, 126, 0, 238, 0, 154, 0, 187, 0, 193, 0, 194, 0, 199, 0, 189, 0, 192, 0, 199, 0, 205, 0, 210, 0, 207, 0, 184, 0, 175, 0, 165, 0, 162, 0, 245, 0, 157, 0, 189, 0, 191, 0, 192, 0, 195, 0, 198, 0, 202, 0, 205, 0, 207, 0, 206, 0, 203, 0, 176, 0, 190, 0, 190, 0, 188, 0, 252, 0, 160, 0, 192, 0, 195, 0, 199, 0, 202, 0, 205, 0, 209, 0, 212, 0, 216, 0, 214, 0, 213, 0, 207, 0, 220, 0, 1, 1, 27, 1, 1, 1, 165, 0, 195, 0, 198, 0, 201, 0, 203, 0, 207, 0, 213, 0, 220, 0, 222, 0, 223, 0, 225, 0, 222, 0, 220, 0, 9, 1, 47, 1, 9, 1, 179, 0, 199, 0, 201, 0, 203, 0, 207, 0, 210, 0, 217, 0, 227, 0, 239, 0, 253, 0, 7, 1, 4, 1, 6, 1, 39, 1, 49, 1, 13, 1, 188, 0, 202, 0, 203, 0, 205, 0, 209, 0, 208, 0, 222, 0, 243, 0, 8, 1, 63, 1, 101, 1, 96, 1, 83, 1, 66, 1, 55, 1, 45, 1, 210, 0, 204, 0, 237, 0, 31, 1, 47, 1, 204, 0, 250, 0, 57, 1, 48, 1, 175, 1, 113, 1, 83, 1, 81, 1, 73, 1, 64, 1, 0, 8, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 12, 98, 112, 108, 105, 115, 116, 48, 48, 212, 1, 2, 3, 4, 5, 6, 7, 8, 85, 102, 108, 97, 103, 115, 85, 118, 97, 108, 117, 101, 89, 116, 105, 109, 101, 115, 99, 97, 108, 101, 85, 101, 112, 111, 99, 104, 16, 1, 19, 0, 0, 184, 82, 72, 69, 56, 30, 18, 59, 154, 202, 0, 16, 0, 8, 17, 23, 29, 39, 45, 47, 56, 61, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, 0, 0, 61, 241, 0, 0, 61, 117, 0, 0, 3, 65, 0, 0, 179, 72, 255, 255, 239, 17, 0, 2, 95, 196, 0, 0, 0, 77, 0, 0, 0, 12
    exif:MeteringMode: 5
    exif:Model: iPhone SE (2nd generation)
    exif:PhotographicSensitivity: 64
    exif:PixelXDimension: 4032
    exif:PixelYDimension: 3024
    exif:SceneCaptureType: 0
    exif:SceneType: 1
    exif:SensingMethod: 2
    exif:ShutterSpeedValue: 61994/9329
    exif:Software: 15.2.1
    exif:SubjectArea: 2013, 1511, 2217, 1330
    exif:SubSecTimeDigitized: 299
    exif:SubSecTimeOriginal: 299
    exif:thumbnail:Compression: 6
    exif:thumbnail:JPEGInterchangeFormat: 2262
    exif:thumbnail:JPEGInterchangeFormatLength: 6219
    exif:thumbnail:ResolutionUnit: 2
    exif:thumbnail:XResolution: 72/1
    exif:thumbnail:YResolution: 72/1
    exif:WhiteBalance: 0
    exif:YCbCrPositioning: 1
    icc:copyright: Copyright Apple Inc., 2017
    icc:description: Display P3
    jpeg:colorspace: 2
    jpeg:sampling-factor: 2x2,1x1,1x1
    signature: af9e98943dd7fc2ab0c2f3aab88ee544a7978e9729349a165b77ec765bfdd9ae
    unknown: iPhone SE (2nd generation)
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 2754240B
  Number pixels: 12.1928M
  Pixels per second: 71.7668MP
  User time: 0.170u
  Elapsed time: 0:01.169
  Version: ImageMagick 7.1.0-26 Q16-HDRI x86_64 2022-02-21 https://imagemagick.org

TXP Builders – finely-crafted code, design and txp

Offline

#2 2022-02-25 12:12:40

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,702
Website

Re: Thumbnail creation can result in rotated / upside-down images

Looks like class.thumb.php needs to check the exif orientation prior to creating the thumb.

See this stackoverflow post and this medium post.

If it helps, this is the output of PHP’s exif_read_data from within Textpattern (i.e. /image/1.jpg) for the above image that shows upside down:

array (
  'FileDateTime' => 0,
  'FileSize' => 2754240,
  'FileType' => 2,
  'MimeType' => 'image/jpeg',
  'SectionsFound' => 'ANY_TAG, IFD0, THUMBNAIL, EXIF',
  'COMPUTED' => 
  array (
    'html' => 'width="4032" height="3024"',
    'Height' => 3024,
    'Width' => 4032,
    'IsColor' => 1,
    'ByteOrderMotorola' => 1,
    'ApertureFNumber' => 'f/1.8',
    'Thumbnail.FileType' => 2,
    'Thumbnail.MimeType' => 'image/jpeg',
  ),
  'Make' => 'Apple',
  'Model' => 'iPhone SE (2nd generation)',
  'Orientation' => 3,
  'XResolution' => '72/1',
  'YResolution' => '72/1',
  'ResolutionUnit' => 2,
  'Software' => '15.2.1',
  'DateTime' => '2022:02:24 19:18:43',
  'HostComputer' => 'iPhone SE (2nd generation)',
  'YCbCrPositioning' => 1,
  'Exif_IFD_Pointer' => 252,
  'THUMBNAIL' => 
  array (
    'Compression' => 6,
    'XResolution' => '72/1',
    'YResolution' => '72/1',
    'ResolutionUnit' => 2,
    'JPEGInterchangeFormat' => 2262,
    'JPEGInterchangeFormatLength' => 6219,
  ),
  'ExposureTime' => '1/100',
  'FNumber' => '9/5',
  'ExposureProgram' => 2,
  'ISOSpeedRatings' => 64,
  'ExifVersion' => '0232',
  'DateTimeOriginal' => '2022:02:24 19:18:43',
  'DateTimeDigitized' => '2022:02:24 19:18:43',
  'ComponentsConfiguration' => '' . "\0" . '',
  'ShutterSpeedValue' => '61994/9329',
  'ApertureValue' => '54823/32325',
  'BrightnessValue' => '283218/59213',
  'ExposureBiasValue' => '0/1',
  'MeteringMode' => 5,
  'Flash' => 16,
  'FocalLength' => '399/100',
  'SubjectLocation' => 
  array (
    0 => 2013,
    1 => 1511,
    2 => 2217,
    3 => 1330,
  ),
  'MakerNote' => 'Apple iOS',
  'SubSecTimeOriginal' => '299',
  'SubSecTimeDigitized' => '299',
  'FlashPixVersion' => '0100',
  'ColorSpace' => 65535,
  'ExifImageWidth' => 4032,
  'ExifImageLength' => 3024,
  'SensingMethod' => 2,
  'SceneType' => '',
  'ExposureMode' => 0,
  'WhiteBalance' => 0,
  'FocalLengthIn35mmFilm' => 28,
  'SceneCaptureType' => 0,
  'UndefinedTag:0xA432' => 
  array (
    0 => '4183519/1048501',
    1 => '4183519/1048501',
    2 => '9/5',
    3 => '9/5',
  ),
  'UndefinedTag:0xA433' => 'Apple',
  'UndefinedTag:0xA434' => 'iPhone SE (2nd generation) back camera 3.99mm f/1.8',
  'UndefinedTag:0xA460' => 2,
)

obtained by putting the following in an article:

<txp:php>
$exif = exif_read_data('http://site.com/images/1.jpg', 'IFD0');
dmp($exif);
</txp:php>

(replacing site.com and the image number with whatever image you want to get the details of)


TXP Builders – finely-crafted code, design and txp

Offline

#3 2022-02-25 21:23:56

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,413
Website GitHub

Re: Thumbnail creation can result in rotated / upside-down images

Weird. I wonder why it needs to check the exif data when that’s largely proprietary, compared to using IPTC metadata or equivalent?

We can (should?) probably check orientation first somehow before creating the thumbnail so leave it with me and I’ll fold it into the image branch. Please create an issue so we can track it, thanks.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#4 2022-02-26 00:49:40

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,138
Website

Re: Thumbnail creation can result in rotated / upside-down images

I still find it strange that this never came up earlier. iPhones (and other digital cameras or phones) have been writing those EXIF meta data since forever.

Or ? Has there been a change in what data iOS includes when uploading images?


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#5 2022-02-26 08:17:21

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,413
Website GitHub

Re: Thumbnail creation can result in rotated / upside-down images

phiw13 wrote #332831:

I still find it strange that this never came up earlier.

Ditto. This is what concerns me: that we’ll put something in place to check/fix the rotation and then find it’s only specific to one device or brand, and it screws up the experience for other people. Something has to have changed somewhere.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#6 2022-02-26 09:24:54

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,138
Website

Re: Thumbnail creation can result in rotated / upside-down images

A test with my iPhoneSE(1st gen) + iOS 15latest and Textpattern 4.8.8 with PHP 8.1.1 & GD 2.3.3

  • Take a landscape image from laptop keyboard in front of me – close enough to only have the keyboard + trackpad.
  • in Photos.app the image shows in portrait mode.
  • The image uploaded to Textpattern is displayed as portrait mode – but the generated thumbnail is displayed as a landscape image (“rotated”).

test 2:

  • same as test 1, but keep some of the surroundings (screen, part of table, a glass of water…).
  • In Camera.app (and then in Photos.app) the image is immediately rotated
  • uploading to Textpattern shows the expected landscape image in all cases (no unexpected rotations)

If I manually rotate the image taken in test 1 in Photos.app, then the image displays as landscape in all cases.

–^–

Can someone with an Android based phone or a standalone digital camera test this as well ?


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#7 2022-02-26 09:36:14

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,413
Website GitHub

Re: Thumbnail creation can result in rotated / upside-down images

That’s a great test and an intriguing result. I’m away from the laptop at the mo but I’ll do these tests later on Android.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#8 2022-07-22 10:09:16

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,702
Website

Re: Thumbnail creation can result in rotated / upside-down images

This was reported to me again, so I took another look at this problem.

I repeated Philippe’s test with an iPhone 11 and txp 4.8.8 and saw similar results, except that in my case some thumbnails were upside-down. As Philippe observed, the iPhone seems to recognize contextual cues and corrects the orientation of the image accordingly even though the camera is held in exactly the same orientation.

I posted an issue on GitHub along with details of the test and screenshots of what Textpattern 4.8.8. produces as thumbnails.

I also did some more research and with the help of a Stackoverflow thread and some experimentation I came up with a potential solution, also detailed in the above issue. I tested with some images of my own and also test images found on the internet for (mirrored) orientations that I couldn’t work out how to produce myself. Perhaps some other people could test this more extensively, especially with images from other cameras?


TXP Builders – finely-crafted code, design and txp

Offline

#9 2022-07-23 00:57:11

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,138
Website

Re: Thumbnail creation can result in rotated / upside-down images

jakob wrote #333732:

This was reported to me again, so I took another look at this problem.

Out of curiosity, what type of (real-world) images are producing those unexpected results? I once asked “iphone” girl who used to used to upload many (travel / food) images taken with said iPhone. She did not remember having run into that issue.

That said, that StackOverflow thread is interesting – as in: over 10years old, and both Android and iOS cameras seem affected. The issue is apparently not new at all.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#10 2022-07-23 07:04:40

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,702
Website

Re: Thumbnail creation can result in rotated / upside-down images

phiw13 wrote #333734:

Out of curiosity, what type of (real-world) images are producing those unexpected results? I once asked “iphone” girl who used to used to upload many (travel / food) images taken with said iPhone. She did not remember having run into that issue.

Yes, I don’t know why we’re seeing it more often now (newer cameras? newer PHP? newer browsers?) but you can try the images I posted in the second comment of the GitHub issue.

Here’s a screenshot of the test images I took with my phone in different orientations plus corresponding txp-generated thumbnails. Images 1-4 are before the patch is replied, 5-8 after the patch is applied.

Screenshot (linked as Textile images are still not working here on the forum)

Also try the prepared test images from github.com/recurser/exif-orientation-examples in all EXIF orientations.

EDIT: And here are two screenshots of the results of that before patch and after patch.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB