Bug 196692 - Red and blue channels in images are reversed when saving
Summary: Red and blue channels in images are reversed when saving
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: ImageEditor-Save (show other bugs)
Version: 1.0.0
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-16 00:25 UTC by sachamasry
Modified: 2022-02-03 03:58 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 1.0.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sachamasry 2009-06-16 00:25:54 UTC
Version:           0.10.0 (using KDE 4.2.2)
OS:                Linux
Installed from:    Fedora RPMs

When saving images through the editor (whether the images have been edited or even just saved-as, to .png format, digikam reverses the red and blue channels.

How can this be prevented, and how can channels on 'damaged' photographs be reversed back?
Comment 1 caulier.gilles 2009-06-16 06:17:24 UTC
I can never confirm this problem. I always use PNG in my workflow

Which CPU do you use (big or little endian)?

Which libpng ? (go to Help/Components Info for details)

Gilles Caulier
Comment 2 sachamasry 2009-06-16 11:42:37 UTC
I am running Fedora core 10 on my PowerMac G5 (big endian).

LibPNG 1.2.35.

The photos, when saved, become predominantly blue. Looking at the histogram,
and filtering for the green channel on the before and after image shows the
same curve and area and statistics. When comparing the red and blue
channels, the shape of the curve and area have been swapped between the red
and blue channels, as have the statistics. I can see no other change. This
does not seem to occur when saving to jpeg, for example.

For what its worth, I used the batch convert images function on the original
from-the-camera jpegs, to convert to png, and all photos were fine. However,
when saving from the editor (still in png, or other images to png) the
damage occurs.

Sacha
Comment 3 caulier.gilles 2009-06-16 11:52:00 UTC
Marcel,

I remember your comments in PNGLoader code about big/little endian support :

http://lxr.kde.org/source/extragear/graphics/digikam/libs/dimg/loaders/pngloader.cpp#224

Sound like comment is not validated by Sacha.

Sacha, 

Do you use digiKam code from trunk ? If no, i recommend to checkout and compile this code to be able to test future changes in live...

Gilles Caulier
Comment 4 sachamasry 2009-06-16 16:39:06 UTC
Gilles,

The digiKam I used was a package (.rpm) from a Fedora repository.

I have followed the instructions, and have checked out the latest svn
digiKam repository (as well as the rest), and have updated packages or
compiled new versions of all relevant dependencies.

So, I am now running digiKam 1.0.0-beta2 (rev.: 982586), using KDE 4.2.3,
and libPNG version 1.2.37.

It does exactly the same thing. I just 'saved as' an existing .png to a new
filename (keeping it .png), and it is displayed with a heavy blue cast in
the main window. Again, the histogram shows that the red and blue channels
have been 'cleanly' swapped, i.e. with no other noticable side effect or
aberration.

Sacha
Comment 5 Marcel Wiesweg 2009-07-27 17:39:43 UTC
Sacha:
Loading PNG images generated elsewhere works fine, and PNG images generated by digikam show the same wrong colors when loaded in other software?
Are you using 16bit or 8bit color depth?

Do you have an SVN checkout of trunk so that you can test any changes introduced?
Comment 6 sachamasry 2009-07-28 00:15:24 UTC
Yes, images created elsewhere are fine. Images processed in batch mode by
DigiKam are fine (inside and in other programs), and (.png) images edited in
DigiKam and saved (in .png), show the wrong colours in all programs, not
just DigiKam (gimp, gwenview, gqview, gthumb, nautilus, etc.)

I'm using 8-bit colour depth, but I've just tried 16 bit, with the same
results.

I've just upgraded from 1.0.0-beta2 via svn to 1.0.0-beta4 and cannot even
start the software. Upon first run, it opened normally, re-opened my last
viewed album (the one with the photos with the swapped channels), started
building the thumbnail previews for the photos in the album, and as soon as
it had reached the last preview, crashed. Since then I can no longer open
DigiKam at all. Running from console looks like this:

digikam(13753)/digikam (core) main: Database Path:  "/home/sacha/Pictures"
digikam(13753)/digikam (core) Digikam::SchemaUpdater::update: SchemaUpdater
update
digikam(13753)/digikam (core) Digikam::SchemaUpdater::startUpdates: Have a
database structure version  "5"
digikam(13753)/digikam (core) Digikam::SchemaUpdater::makeUpdates:
makeUpdates  5  to  5
digikam(13753)/digikam (core) Digikam::AlbumRootLocation::AlbumRootLocation:
Creating new Location  "/"  uuid
"volumeid:?path=%2Fhome%2Fsacha%2FPictures"
digikam(13753)/digikam (core) Digikam::CollectionManager::updateLocations:
location for  "/home/sacha/Pictures"  is available  true
digikam(13753) Digikam::ThumbnailLoadThread::initializeThumbnailDatabase:
Thumbnail db ready for use
digikam(13753)/digikam (core) Digikam::AlbumManager::startScan: KDirWatch
method =  "FAM"
Segmentation fault


Sacha

On Mon, Jul 27, 2009 at 4:39 PM, Marcel Wiesweg <marcel.wiesweg@gmx.de>wrote:

> https://bugs.kde.org/show_bug.cgi?id=196692
>
>
>
>
>
> --- Comment #5 from Marcel Wiesweg <marcel wiesweg gmx de>  2009-07-27
> 17:39:43 ---
> Sacha:
> Loading PNG images generated elsewhere works fine, and PNG images generated
> by
> digikam show the same wrong colors when loaded in other software?
> Are you using 16bit or 8bit color depth?
>
> Do you have an SVN checkout of trunk so that you can test any changes
> introduced?
>
> --
> Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You reported the bug.
>
Comment 7 caulier.gilles 2009-07-28 06:30:52 UTC
Sacha,

Run digiKam into GDB to see backtrace. Look here for details :

http://www.digikam.org/contrib

Gilles Caulier
Comment 8 Marcel Wiesweg 2009-07-30 15:50:08 UTC
SVN commit 1004564 by mwiesweg:

Use some call for writing as for reading. May explain swapped blue and red channels.

CCBUG: 196692

 M  +2 -1      pngloader.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1004564
Comment 9 sachamasry 2009-07-30 19:55:01 UTC
Gilles,

Here is your debug output:


gdb digikam
GNU gdb Fedora (6.8-29.fc10)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "ppc-redhat-linux-gnu"...
(gdb) run
Starting program: /usr/bin/digikam
[Thread debugging using libthread_db enabled]
[New Thread 0xf7be4000 (LWP 13524)]
digikam(13524)/digikam (core) main: Database Path:  "/home/sacha/Pictures"
[New Thread 0xf5894400 (LWP 13535)]
digikam(13524)/digikam (core) Digikam::SchemaUpdater::update: SchemaUpdater
update
digikam(13524)/digikam (core) Digikam::SchemaUpdater::startUpdates: Have a
database structure version  "5"
digikam(13524)/digikam (core) Digikam::SchemaUpdater::makeUpdates:
makeUpdates  5  to  5
digikam(13524)/digikam (core) Digikam::AlbumRootLocation::AlbumRootLocation:
Creating new Location  "/"  uuid
"volumeid:?path=%2Fhome%2Fsacha%2FPictures"
digikam(13524)/digikam (core) Digikam::CollectionManager::updateLocations:
location for  "/home/sacha/Pictures"  is available  true
digikam(13524) Digikam::ThumbnailLoadThread::initializeThumbnailDatabase:
Thumbnail db ready for use
[New Thread 0xf48ff400 (LWP 13537)]
[New Thread 0xf3eff400 (LWP 13538)]
[New Thread 0xf34ff400 (LWP 13539)]
[New Thread 0xf2aff400 (LWP 13540)]
[New Thread 0xf20ff400 (LWP 13541)]
[New Thread 0xf16ff400 (LWP 13542)]
[New Thread 0xef84b400 (LWP 13544)]
[New Thread 0xeea40400 (LWP 13545)]
[New Thread 0xee040400 (LWP 13546)]
[New Thread 0xe9594400 (LWP 13547)]
[Thread 0xe9594400 (LWP 13547) exited]
[New Thread 0xe9594400 (LWP 13548)]
[Thread 0xe9594400 (LWP 13548) exited]
[New Thread 0xe9594400 (LWP 13549)]
[New Thread 0xe8b94400 (LWP 13550)]
[New Thread 0xe8194400 (LWP 13551)]
[Thread 0xe8194400 (LWP 13551) exited]
[Thread 0xe8b94400 (LWP 13550) exited]
[Thread 0xe9594400 (LWP 13549) exited]
[New Thread 0xe9594400 (LWP 13552)]
[New Thread 0xe8b94400 (LWP 13559)]
[New Thread 0xe8194400 (LWP 13564)]
digikam(13524)/digikam (core) Digikam::AlbumManager::startScan: KDirWatch
method =  "FAM"

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xe8b94400 (LWP 13559)]
0x0ea39788 in ClearBitBlock (stream=0xe8b921e4, pos=80966, len=65536)
    at
/home/sacha/Desktop/digikam/graphics/digikam/libs/3rdparty/libpgf/BitStream.h:159
159                stream[i] = 0;
Missing separate debuginfos, use: debuginfo-install
digikam-0.10.0-1.fc10.ppc
(gdb) bt
#0  0x0ea39788 in ClearBitBlock (stream=0xe8b921e4, pos=80966, len=65536)
    at
/home/sacha/Desktop/digikam/graphics/digikam/libs/3rdparty/libpgf/BitStream.h:159
#1  0x0ea37268 in CDecoder::RLDSigsAndSigns (this=0x119dad20,
    bufferSize=8192, codeLen=18564, sigBits=0xe8b921e4, signBits=0xe8b929e4)
    at
/home/sacha/Desktop/digikam/graphics/digikam/libs/3rdparty/libpgf/Decoder.cpp:729
#2  0x0ea376c0 in CDecoder::BitplaneDecode (this=0x0, bufferSize=0)
    at
/home/sacha/Desktop/digikam/graphics/digikam/libs/3rdparty/libpgf/Decoder.cpp:539
#3  0x00000000 in ?? ()

I'm gone for a couple of weeks in three days. If there's anything else I can
suply/try, please let me know.

Sacha


On Tue, Jul 28, 2009 at 5:30 AM, Gilles Caulier <caulier.gilles@gmail.com>wrote:

> https://bugs.kde.org/show_bug.cgi?id=196692
>
>
> Gilles Caulier <caulier.gilles@gmail.com> changed:
>
>           What    |Removed                     |Added
>
> ----------------------------------------------------------------------------
>             Version|0.10.0                      |1.0.0-beta3
>
>
>
>
> --- Comment #7 from Gilles Caulier <caulier gilles gmail com>  2009-07-28
> 06:30:52 ---
> Sacha,
>
> Run digiKam into GDB to see backtrace. Look here for details :
>
> http://www.digikam.org/contrib
>
> Gilles Caulier
>
> --
> Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You reported the bug.
>
Comment 10 caulier.gilles 2009-07-30 20:45:20 UTC
sachamasry,

Problem i know and fixed today in svn by this commit :

http://websvn.kde.org/?view=rev&revision=1004398

Gilles Caulier
Comment 11 rishi.j.sanyal 2009-07-31 12:31:51 UTC
Marcel,

I'm here... what exactly do you want me to test? The latest SVN version compiles and runs fine on my Mac OS X as long as all my KDE libraries are version 4.2.0, not higher.

Do you want me to see I can save PNG files properly?

Please clarify.

Thanks,
Rishi
Comment 12 caulier.gilles 2009-07-31 12:36:10 UTC
Yes load and save PNG or TIFF, or JPEG, and look if loading image to another program as gimp give right result with colors.

Gilles Caulier

Note : i think Marcel need tests with MacOS x running under PowerPcc computer.
Comment 13 sachamasry 2009-07-31 13:01:25 UTC
No improvement, check output below:

[sacha@G5 ~]$ digikam -v
Qt: 4.5.0
KDE: 4.2.3 (KDE 4.2.3)
digiKam: 1.0.0-beta4 (rev.: 1004797)
[sacha@G5 ~]$ gdb digikam
GNU gdb Fedora (6.8-29.fc10)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "ppc-redhat-linux-gnu"...
(gdb) run
Starting program: /usr/bin/digikam
[Thread debugging using libthread_db enabled]
[New Thread 0xf7be4000 (LWP 7208)]
digikam(7208)/digikam (core) main: Database Path:  "/home/sacha/Pictures"
[New Thread 0xf5a9a400 (LWP 7218)]
digikam(7208)/digikam (core) Digikam::SchemaUpdater::update: SchemaUpdater
update
digikam(7208)/digikam (core) Digikam::SchemaUpdater::startUpdates: Have a
database structure version  "5"
digikam(7208)/digikam (core) Digikam::SchemaUpdater::makeUpdates:
makeUpdates  5  to  5
digikam(7208)/digikam (core) Digikam::AlbumRootLocation::AlbumRootLocation:
Creating new Location  "/"  uuid
"volumeid:?path=%2Fhome%2Fsacha%2FPictures"
digikam(7208)/digikam (core) Digikam::CollectionManager::updateLocations:
location for  "/home/sacha/Pictures"  is available  true
digikam(7208) Digikam::ThumbnailLoadThread::initializeThumbnailDatabase:
Thumbnail db ready for use
[New Thread 0xf4cd9400 (LWP 7220)]
[New Thread 0xf42d9400 (LWP 7221)]
[New Thread 0xf385b400 (LWP 7222)]
[New Thread 0xf2e5b400 (LWP 7223)]
[New Thread 0xf245b400 (LWP 7224)]
[New Thread 0xf1a5b400 (LWP 7225)]
[New Thread 0xefa1b400 (LWP 7226)]
[New Thread 0xeec10400 (LWP 7227)]
[New Thread 0xee210400 (LWP 7228)]
[New Thread 0xe977a400 (LWP 7229)]
[Thread 0xe977a400 (LWP 7229) exited]
[New Thread 0xe977a400 (LWP 7230)]
[Thread 0xe977a400 (LWP 7230) exited]
[New Thread 0xe977a400 (LWP 7231)]
[New Thread 0xe8d7a400 (LWP 7232)]
[New Thread 0xe837a400 (LWP 7233)]
[Thread 0xe837a400 (LWP 7233) exited]
[Thread 0xe8d7a400 (LWP 7232) exited]
[Thread 0xe977a400 (LWP 7231) exited]
[New Thread 0xe977a400 (LWP 7234)]
[New Thread 0xe8d7a400 (LWP 7236)]
[New Thread 0xe837a400 (LWP 7239)]
digikam(7208)/digikam (core) Digikam::AlbumManager::startScan: KDirWatch
method =  "FAM"

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xe8d7a400 (LWP 7236)]
0x0ea3a578 in ClearBitBlock (stream=0xe8d781e4, pos=80966, len=65536)
    at
/home/sacha/Desktop/digikam/graphics/digikam/libs/3rdparty/libpgf/BitStream.h:159
159                stream[i] = 0;
Missing separate debuginfos, use: debuginfo-install
digikam-0.10.0-1.fc10.ppc
(gdb)


On Thu, Jul 30, 2009 at 7:45 PM, Gilles Caulier <caulier.gilles@gmail.com>wrote:

> https://bugs.kde.org/show_bug.cgi?id=196692
>
>
>
>
>
> --- Comment #10 from Gilles Caulier <caulier gilles gmail com>  2009-07-30
> 20:45:20 ---
> sachamasry,
>
> Problem i know and fixed today in svn by this commit :
>
> http://websvn.kde.org/?view=rev&revision=1004398
>
> Gilles Caulier
>
> --
> Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You reported the bug.
>
Comment 14 caulier.gilles 2009-07-31 13:16:13 UTC
Sasha,

recompile digiKam with libpgf thumbs database disable, using this cmake option :

"-DENABLE_THUMBS_DB=no"

Gilles Caulier
Comment 15 Marcel Wiesweg 2009-07-31 17:24:55 UTC
Rishi: Thanks for your help. The problem here is saving of PNG images but on Big Endian machines, I forgot that your machine, if an Intel Apple, is Little Endian (is it?) then you will probably not have this problem.
Sacha here has reported a problem but has now problems getting digikam to run at all.

Sacha: my commit (comment #8) may have fixed the problem, but I can't test.
Comment 16 rishi.j.sanyal 2009-07-31 21:18:35 UTC
Marcel,

Yes, Intel Mac, Little Endian is what I have.

I'm surprised Sacha even got digiKam running for longer than 2 seconds using KDE 4.2.3 (if I read correctly).

-Rishi
Comment 17 sachamasry 2009-08-01 16:06:51 UTC
Updated to revision 1005312.

It seems to be working well now. There is no further swapping of channels on
(8bit) png images.

I have not had time to test it out seriously, but now I can start using
DigiKam in my RAW-PNG workflow.

Thanks for all the help Gilles, Marcel et al.


Sacha

On Fri, Jul 31, 2009 at 4:25 PM, Marcel Wiesweg <marcel.wiesweg@gmx.de>wrote:

> https://bugs.kde.org/show_bug.cgi?id=196692
>
>
>
>
>
> --- Comment #15 from Marcel Wiesweg <marcel wiesweg gmx de>  2009-07-31
> 17:24:55 ---
> Rishi: Thanks for your help. The problem here is saving of PNG images but
> on
> Big Endian machines, I forgot that your machine, if an Intel Apple, is
> Little
> Endian (is it?) then you will probably not have this problem.
> Sacha here has reported a problem but has now problems getting digikam to
> run
> at all.
>
> Sacha: my commit (comment #8) may have fixed the problem, but I can't test.
>
> --
> Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You reported the bug.
>
Comment 18 rishi.j.sanyal 2009-12-25 19:51:17 UTC
I'm sorry guys, I can't test anything b/c I can't compile digiKam b/c Qt4 port is broken. It won't compile on my Mac (OS X 10.6.2). Crossing my fingers it'll be fixed soon.