Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#22259 closed defect (bug) (fixed)

Round image EXIF float data.

Reported by: jcakec's profile jcakec Owned by: nacin's profile nacin
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.5
Component: Media Keywords: has-patch
Focuses: Cc:

Description

Hello,

On changeset 21292 you made some changes to stripslashes as follows: Only run stripslashes() in stripslashes_deep() for strings.

Prior to these changes, when you called wp_read_image_metadata() all values were saved as strings. Now they are saves as the correct type, but as floats are approximations, instead of getting values like 0.0004 we are getting values of 0.0004000000000000000191686944095437183932517655193805694580078125

These values are making some galleries to misbehave with EXIF data, so could we round the values so we don't get these huge numbers, and that way we can still use the current plugins and widgets while the owners update them.

Attachments (2)

image.php.patch (1.0 KB) - added by jcakec 12 years ago.
image.php.2.patch (1.0 KB) - added by jcakec 12 years ago.
Changed the round 4 to round 7 so it rounds according to standards.

Download all attachments as: .zip

Change History (6)

@jcakec
12 years ago

#1 @scribu
12 years ago

  • Component changed from General to Media
  • Milestone changed from Awaiting Review to 3.5
  • Version set to trunk

#2 follow-up: @nacin
12 years ago

We also round aperture already, so this makes sense. But is 4 the maximum number of decimal places we'd ever have here? To keep existing behavior, simply casting to a string should be sufficient, right?

#3 in reply to: ↑ 2 @jcakec
12 years ago

Replying to nacin:

We also round aperture already, so this makes sense. But is 4 the maximum number of decimal places we'd ever have here? To keep existing behavior, simply casting to a string should be sufficient, right?

Well, according to http://en.wikipedia.org/wiki/Shutter_speed the maximum speed can be 1/16000 s, so that's 0.0000625, so 7 seems to be better value than 4, but most of the images I've seen during my tests had 0.0004 as the lowest value.

casting everything to string would be sufficient? yes it would be, but would that be the better approach? I left that question to you guys, as you're the experts. :)

@jcakec
12 years ago

Changed the round 4 to round 7 so it rounds according to standards.

#4 @nacin
12 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 22319:

Cast image metadata focal_length and shutter_speed to strings to restore previous behavior when stripslashes_deep() converted these values. Avoids rounding errors without making a determination of which digit we should round to. props jcakec. fixes #22259.

Note: See TracTickets for help on using tickets.