Don't always recompress contact photos when saving

Review Request #106745 - Created Oct. 6, 2012 and submitted

Information
Sebastian Scheibner
kdepimlibs
307570
Reviewers
kdepimlibs
When changing a contact with a photo, the photo is recompressed when saving (even though the photo wasn't changed). That's because the photo is loaded into a QImage and when the contact is saved, the QImage is compressed as JPEG again (or PNG if it contains an alpha-channel, which most don't).

This patch stores the raw base64 photo data from the vcard as a QByteArray in KABC::Picture. If the photo is not changed, this QByteArray is simply used when saving the contact, so there's no recompression and quality loss. If the photo was changed it gets compressed as JPEG as before.

fixes this bug: https://bugs.kde.org/show_bug.cgi?id=307570
compiled kdepimlibs/kabc with kde 4.9.2

- created a new contact in kaddressbook and added a photo. exported the contact.
- changed the photo and exported the contact again
- the image data in the exported file didn't change

Issues

  • 3
  • 1
  • 0
  • 4
Description From Last Updated
I think for compatibility you'll need to have it like this return s << picture.d->mIntern << picture.d->mUrl << picture.d->mType << ... Kevin Krammer Kevin Krammer
Here you can keep the old code or read into a temporary QImage and call setData on picture Kevin Krammer Kevin Krammer
I think you'll also need to save the type, otherwise pic will have rawData but no type and saving that ... Kevin Krammer Kevin Krammer
Kevin Krammer
Sebastian Scheibner
Kevin Krammer
Sebastian Scheibner
Kevin Krammer
Sebastian Scheibner
Kevin Krammer
Sebastian Scheibner
Kevin Krammer
Commit Hook
This review has been submitted with commit c0a50e2b6e7a8513d0a768afb35bc7aa3d1748f1 by Allen Winter to branch master.
Sebastian Scheibner
Review request changed

Status: Closed (submitted)

Loading...