READ_PNG not working with palette

1 2 > >> (Page 1 of 2)
  • Daniel Molina

    Daniel Molina - 2012-02-02

    Nor function nor procedure form of READ_PNG are working for me

    image = READ_IMAGE(filename, r, g, b)


    READ_IMAGE, filename, image, r, g, b

    PRINT, r

    % PRINT: Variable is undefined: R
    % Execution halted at: $MAIN$ 

  • Alain C.

    Alain C. - 2012-02-02

    Thanks for this useful bug report. I am able to reproduce it on two PNG we previously used. In the code, it is clear for me that, because the image are detected without indexedcolor (via the test
    magick_IndexedColor(mid) ) the RGB info are not read. Because I know nothing on PNG format I don't know if it is "normal" or not. Nevertheless I will look for a solution.

    It would great to have few references (JPEG, PNG) to be able to use then as test cases.
    (or standardized transformations from the testsuite/Saturn.jpg image). Any suggestions ?

    When reporting a problem related to Image Magick (IM), please in the future also provide the version of IM you used, we clearly had problems in tricky bugs coming from IM in the past.

  • Alain C.

    Alain C. - 2012-02-02

    OK, thanks to your bug report, I found the way to correct the way READ_PNG reads PNG images (w/o transparency): the colors are now OK in TV, image_png, /true

    But, after testing also in IDL, I found it is OK not to have R,B,G for TrueColor (24b) images. If you have a link to problematic PseudoColor image, I am ready !


  • Daniel Molina

    Daniel Molina - 2012-02-03

    I confirm that the image of the last link fails when loading with READ_PNG of my GDL version (not the last development one, but not too old) but not with IDL, which loads correctly r, g and b arrays of the color table.

  • Alain C.

    Alain C. - 2012-02-05

    thanks for the classification, that is a good starting point !

    the 2 JPEG are OK for me (using last CVS and 7: )
    only the PNG 1 and 3 are OK for me
    PNG 2: pb with order (up side down)
    PNG 4: even using TV, im,/true  it is not OK :(

    help/advices welcome !!

  • Alain C.

    Alain C. - 2012-02-06

    I put a new file in testsuite:
    Now I think the problems are much more clear:
    - TVLCT is not working (then PNG with palete are not well managed)
    - PNG with 2 channels are read as 2D image
    - up-side-down is 2 cases

  • Alain C.

    Alain C. - 2012-02-07

    OK, now all the 6 cases in "testsuite/" are ok in CVS. (and others ones ;-)
    Please report expecially pbs within them.

    Please report also any other problems (with links to images).

    I have no time now to check further the writing part for JPEG and PNG, help welcome.

    I also had no practical interested to check the others formats, then please report, in the bug repport tracker, any problem.

  • Daniel Molina

    Daniel Molina - 2012-02-21

    Just for understanding better alpha-channel/transparency of png images, first lines of this IDL program can be useful (although I have not time just now for looking deeper.

    By the way, those say that "IDL 6.5 or higher required to correctly display alpha images.".

  • Daniel Molina

    Daniel Molina - 2012-03-22


    I'm testing the JPEG-1 channel (grayscale) image

    When loading,

    read_jpeg, '640px-Lubinus_Duchy_of_Pomerania_Map_1618_monocromatic.jpg', image
    % MAGICK_READINDEXES: (FIXME!) Magick's getIndexes() returned NULL for: MID

    I looked into the code. BaseGDL * magick_ping(EnvT* e) believes that the image has palette, but it hasn't, since it is a grayscale image. So, I believe that something is wrong in that function. At any case, if a force variable has_palette to 1, error happens also.

    I don't know where is defined the type "Image", and I need to know a bit about it for understanding how works classType() in order to looking for the error deeper.

  • Daniel Molina

    Daniel Molina - 2012-03-22

    I did a typo.

    > At any case, if a force variable has_palette to 1, error happens also.

    I wanted to say that I forced it to 0, that is, without palette

  • Alain C.

    Alain C. - 2012-03-29

    I tested your last example on 3 different computers (CentOS, Ubuntu, Debian) with current CVS version and I was not able to reproduce your problem. Could you check carefully if:
    1/ you used a "current" CVS version of GDL
    2/ you did upgrade too the files in the src/pro directory (I made changes in read_jpeg and other *pro some time ago)

    If you still have problem, please report here the Image Magick version you use.


  • Daniel Molina

    Daniel Molina - 2012-04-02

    Idem for ImageMagick-6.7.3-0 and ImageMagick-6.7.0-10.

  • Daniel Molina

    Daniel Molina - 2012-04-24


    Any clue in advance about what's the cause? Known versions of Magick which are working? I'd like helping to fix the issue since quite a lot of my code is involved. I didn't write in C++ before, but I can waste some time reading the related code, but a bit orientation about what watching would be nice.


  • Alain C.

    Alain C. - 2012-05-04

    OK, I can reproduce your problem on the current Ubuntu 12.04 then I will start now to look for a solution. Sorry for the delay but I was not able to reproduce before (we just upgrade a machine to the 12.04)

    Image Magick version is:

  • Alain C.

    Alain C. - 2012-05-07

    OK. We do have terrible problems with old AND recent Image Magick library (and also bugs in GDL, another story !!)

    old version
    $ identify -version
    Version: ImageMagick 6.6.0-4 2012-04-24 Q16

    $ identify -unique 589px-Lavandula_spica_monochrome.png 640px-Lubinus_Duchy_of_Pomerania_Map_1618_monocromatic.jpg Indexed_palette.png
    589px-Lavandula_spica_monochrome.png PNG 589x480 589x480+0+0 8-bit PseudoClass 256c 121KB 0.010u 0:00.000
    640px-Lubinus_Duchy_of_Pomerania_Map_1618_monocromatic.jpg JPEG 640x368 640x368+0+0 8-bit PseudoClass 256c 108KB 0.000u 0:00.000
    Indexed_palette.png PNG 150x401 150x401+0+0 8-bit PseudoClass 242c 4.21KB 0.030u 0:00.010

    new version (ubuntu 12.04)

    $ identify -version
    Version: ImageMagick 6.6.9-7 2012-04-30 Q16

    $ identify -unique 589px-Lavandula_spica_monochrome.png 640px-Lubinus_Duchy_of_Pomerania_Map_1618_monocromatic.jpg  Indexed_palette.png
    589px-Lavandula_spica_monochrome.png PNG 589x480 589x480+0+0 8-bit DirectClass 121KB 0.000u 0:00.000
    640px-Lubinus_Duchy_of_Pomerania_Map_1618_monocromatic.jpg JPEG 640x368 640x368+0+0 8-bit PseudoClass 256c 108KB 0.000u 0:00.000
    Indexed_palette.png PNG 150x401 150x401+0+0 8-bit PseudoClass 242c 4.21KB 0.000u 0:00.000

    BUT, in fact, inside the internal call to Magick++, we receive another result (good in the old, bad in the new)

    in magick_ping()
    a.type() =1 always for the new IM lib :((

    with old:
    a=query_image('../TestOnImages/589px-Lavandula_spica_monochrome.png', res) & help,/str, res
    a.type()      :3
    a.classType() :2

    with New:
    GDL> a=query_image('../TestOnImages/Indexed_palette.png', res) & help,/str, res
    a.type()      :1
    a.classType() :2

  • Alain C.

    Alain C. - 2012-05-07

    N.B. to the previous post: a.type() and a.classType() are "cout" I put in the code source of magick_cl.cpp …

    Another crazy fact: testing with "identify -ping " with old CentOS Image Magick code give others results !!!

  • Alain C.

    Alain C. - 2012-05-07

    I found a solution: using GraphicsMagick instead of ImageMagick. The only trick was to create
    a logical link from GraphicsMagick++-config to Magick++-config (and providing
    the good path in configure)

    tested on Ubuntu 10.04 and 12.04 and also CentOS.

    (now only a known reminding bug in GDL is surviving ;-)

    I plan to add hardcoded tests in "testsuite/" to help you to know if
    your IM lib is broken or not.

  • Alain C.

    Alain C. - 2012-05-10

    some news on this topic.
    - in IM or in GM, not a reliable way to recover type of image. is better (but slower).
    - I made a serious systematic study of the behavior of IM and GM on various OS (various Ubuntu, CentOS, various Debian, OSX.). General rules have been derived then propagated in GDL in "src/magick_cl.cpp".
    "testsuite/" was improved in consequence.

    The current version of IM on Ubuntu 12.04 is clearly buggy.
    $ identify -version
    Version: ImageMagick 6.6.9-7 2012-04-30 Q16

    $ gm identify -version
    GraphicsMagick 1.3.12 2010-03-08 Q8

    GM on same computer is OK. You can switch to GM using the configure way
    (0/ changing AM_INIT_AUTOMAKE(color-tests) into AM_INIT_AUTOMAKE in "")
    1/ autoreconf -vfi
    2/ ./configure -without-netcdf -without-wxWidgets -without-python -without-hdf -without-hdf5 -without-Magick -with-GraphicsMagick
    3/ make
    4/ sh ./
    in GDL

  • Daniel Molina

    Daniel Molina - 2012-05-14

    I did 0/, then 1/ which returned

       autoreconf: not using Automake

    between other lines. Then I did

    $ ./configure -without-netcdf -without-wxWidgets -without-python -without-hdf -without-hdf5 -without-Magick -with-GraphicsMagick=/home/lluvia/My_Programs -with-pslib=no -with-plplot=/home/lluvia/My_Programs

    and then $ make, which returned

       Makefile:16: *** missing separator.  Stop.

    So gdl was not compiled.

  • Alain C.

    Alain C. - 2012-05-14

    depending of the OS, step "0" might by optional; also you may need to (re)create dir. m4
    $ mkdir m4
    $ autoreconf -vfi

    $ ./configure


    PS: I run that on CentOS, Various Ubuntu, debian, Suse and OSX, you will success !

    PPS: I found another exception on PNG/JPEG  I am not sure being able to consider this new case in next few days.

  • Daniel Molina

    Daniel Molina - 2012-05-15

    I'm on Ubuntu 10.04 and ./configure seems to not recognize plplot

    When I build and install gdl when i execute it is returned

    ./gdl: error while loading shared libraries: cannot open shared object file: No such file or directory

    This is the result of the configure

    $ ./configure -without-netcdf -without-wxWidgets -without-python -without-hdf -without-hdf5 -without-Magick -with-GraphicsMagick=/home/lluvia/My_Programs -with-pslib=no -with-plplotdir=/home/lluvia/My_Programs -prefix=/home/lluvia/My_Programs/gdl

                      GDL - GNU Data Language
      --- compilation options: ------------------
      System:              i686-pc-linux-gnu
      Installation prefix: /home/lluvia/My_Programs/gdl
      C++ compiler:        g++ -g -O2
      OpenMP support:      yes
      Build type:          standalone (other: Python module)
      --- optional libraries (consult README/INSTALL): --
      wxWidgets:           no
      Magick:              no
      GraphicsMagick:      yes
      NetCDF:              no
      HDF4:                no
      HDF5:                no
      FFTW:                yes
      libproject:          no  (see also MAP_INSTALL)
      MPICH:               no  (needs explicit enabling)
      Python:              no  (see also PYTHON.txt)
      UDUNITS-2:           no  (needs explicit enabling)
      GRIB:                no  (needs explicit enabling)
      GSHHS:               no  (see also MAP_INSTALL)
      Xlib:                yes
      pslib:               no

  • Alain C.

    Alain C. - 2012-05-15

    I would try something like

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/GDL/plplot-5.9.3/Compilation/lib/
    before starting "gdl"

    what does return "ldd gdl" ?

1 2 > >> (Page 1 of 2)

Log in to post a comment.