Make WordPress Core

Opened 12 years ago

Closed 10 years ago

Last modified 10 years ago

#23706 closed defect (bug) (fixed)

Image metadata encoding problem

Reported by: pavelevap's profile pavelevap Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.0 Priority: normal
Severity: normal Version: 3.0
Component: Media Keywords: has-patch needs-unit-tests 3.9-early commit
Focuses: Cc:

Description

I uploaded picture DSCF4480.jpg (attached for testing).

Metadata for title and caption should be the same: "Bystřice u Benešova". But after upload title is right, but caption is damaged:

'caption' => 'Bystøice u Benešova',
'title' => 'Bystřice u Benešova'

Using latest trunk.

Attachments (2)

DSCF4480.JPG (54.7 KB) - added by pavelevap 12 years ago.
23706.patch (3.3 KB) - added by SergeyBiryukov 12 years ago.

Download all attachments as: .zip

Change History (16)

@pavelevap
12 years ago

#1 @SergeyBiryukov
12 years ago

  • Component changed from General to Media
  • Keywords has-patch needs-unit-tests added
  • Milestone changed from Awaiting Review to 3.6
  • Version changed from trunk to 3.0

Introduced in [13244].

iptcparse() returns the correct caption, but the result from exif_read_data() overwrites it:
http://core.trac.wordpress.org/browser/tags/3.5.1/wp-admin/includes/image.php#L244

This is what we get from iptcparse():

Array
(
    [aperture] => 0
    [credit] => mirekk
    [camera] => 
    [caption] => Přístupový chodník k 1.koleji (budoucí směr Tábor)
    [created_timestamp] => 0
    [copyright] => http://www.4koridor.cz
    [focal_length] => 0
    [iso] => 0
    [shutter_speed] => 0
    [title] => Bystřice u Benešova
)

This what we get later after merging with exif_read_data():

Array
(
    [aperture] => 3.2
    [credit] => mirekk
    [camera] => FinePix S9600
    [caption] => Byst�ice u Bene�ova
    [created_timestamp] => 1348422433
    [copyright] => http://www.4koridor.cz
    [focal_length] => 6.2
    [iso] => 100
    [shutter_speed] => 0.00666666666667
    [title] => Bystřice u Benešova
)

According to this reply, the EXIF:ImageDescription tag does not officially support UTF-8.

I guess we should only fill in the missing data instead of stomping on existing values.

#2 @pavelevap
12 years ago

Thank you, Sergey!

I tested your patch and it works really well!

#3 @markjaquith
11 years ago

  • Keywords early added
  • Milestone changed from 3.6 to Future Release

Punting this as we're focusing on 3.6 blockers now. Let's get this done early in 3.7.

#4 @pavelevap
11 years ago

Tested with latest 3.6, there were probably some changes.

Title is the same, but caption is in database without encoding problem now. I am not sure what was changed?

The only strange thing is that caption value is saved in metadata, but displayed as Desription field (in Media library) and Caption field is empty (post_excerpt value)?

#5 @SergeyBiryukov
11 years ago

  • Milestone changed from Future Release to 3.7

#6 @nacin
11 years ago

  • Keywords commit added
  • Milestone changed from 3.7 to 3.8

#7 @kraftbj
11 years ago

  • Cc bk@… added

#8 @nacin
11 years ago

  • Owner set to SergeyBiryukov
  • Status changed from new to assigned

Sergey, if this is good to go, please commit.

#9 @SergeyBiryukov
11 years ago

  • Keywords 3.9-early added; early removed
  • Milestone changed from 3.8 to Future Release

#10 @wonderboymusic
10 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 28367:

In wp_read_image_metadata(), the values from exif_read_data() should only override values from iptcparse() that are empty.

Props SergeyBiryukov.
Fixes #23706.

#11 @wonderboymusic
10 years ago

  • Milestone changed from Future Release to 4.0

#12 follow-up: @pavelevap
10 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Please see my older comment: https://core.trac.wordpress.org/ticket/23706#comment:4

The only strange thing is that caption value is saved in metadata, but displayed as Desription field (in Media library) and Caption field is empty (post_excerpt value)?

And another note. We are saving these really long values into database (you can test attached image)? Is it really needed?

aperture = 3.20000000000000017763568394002504646778106689453125

shutter_speed = 0.0066666666666667

#13 in reply to: ↑ 12 @helen
10 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

Replying to pavelevap:

The only strange thing is that caption value is saved in metadata, but displayed as Desription field (in Media library) and Caption field is empty (post_excerpt value)?

#22768

And another note. We are saving these really long values into database (you can test attached image)? Is it really needed?

Why not keep data that's there? Also, that doesn't seem like a part of this ticket.

#14 @pavelevap
10 years ago

Sorry, I did not notice related ticket.

Should I create another ticket for strange values? I am not sure if it is worth it, but numbers are really long, not sure if really used for something with that presision...

Note: See TracTickets for help on using tickets.