X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 29 Dec 2013 03:15 PM by  anon
Problem with IDL interaction with ImageMagick
 13 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:14
New Member


--
29 Dec 2013 03:15 PM
    I am trying to use the ImageMagick convert command from within IDL to convert a Postscript image (.ps) to a PNG image (.png). I'm using IDL8.2.3 on a Mac under OSX 10.8.5. Working from the shell, I can issue the convert command successfully: bash-3.2$ convert test1.ps test1.png From within IDL however, IDL> spawn, 'ls *.ps' spawn, 'which convert' spawn, 'convert test1.ps test1.png' Error messages: convert: bad parameters to zlib `/var/tmp/magick-30135vlJiOsIjJHDQ1' @ error/png.c/MagickPNGErrorHandler/1804. convert: corrupt image `/var/tmp/magick-30135vlJiOsIjJHDQ1' @ error/png.c/ReadPNGImage/4051. convert: Postscript delegate failed `test1.ps': No such file or directory @ error/ps.c/ReadPSImage/837. convert: no images defined `test1.png' @ error/convert.c/ConvertImageCommand/3144. What does the IDL 'spawn' procedure do that might account for this? Thanks.

    Deleted User



    New Member


    Posts:
    New Member


    --
    30 Dec 2013 03:31 PM
    Dear Barry, I have tested your sequence of steps in Ubuntu 11, for example, and everything seems to be working fine. My system has the following "convert": Version: ImageMagick 6.6.0-4 2012-08-17 Try this, and let me know if that works: IDL>p=plot(/test) IDL>p.save, 'testconvert.ps' IDL>spawn, 'which convert' /usr/bin/convert IDL>spawn, 'testconvert.ps testconvert.png' Does that work? If it does, maybe the issue could be the actual .ps file that you want to convert? Also, try using the full path to convert: spawn, '/opt/local/bin/convert test1.ps test1.png' Cheers, fernando

    Deleted User



    New Member


    Posts:14
    New Member


    --
    30 Dec 2013 04:25 PM
    Hi Fernando, Thanks, but no joy, I'm afraid. I assumed that you meant to include 'convert' in the spawn command. My version of ImageMagick is 6.8.8-0. I wonder if the problem has something to do with the Mac OS and how IDL interacts with it. Barry IDL> p=plot(/test) IDL> p.save, '/Users/blesht/testconvert.ps' IDL> spawn, 'which convert' /opt/local/bin/convert IDL> spawn, 'convert /Users/blesht/testconvert.ps /Users/blesht/testconvert.png' convert: bad parameters to zlib `/var/tmp/magick-42798glCi29mytIDb1' @ error/png.c/MagickPNGErrorHandler/1804. convert: corrupt image `/var/tmp/magick-42798glCi29mytIDb1' @ error/png.c/ReadPNGImage/4051. convert: Postscript delegate failed `/Users/blesht/testconvert.ps': No such file or directory @ error/ps.c/ReadPSImage/837. convert: no images defined `/Users/blesht/testconvert.png' @ error/convert.c/ConvertImageCommand/3144.

    Deleted User



    New Member


    Posts:
    New Member


    --
    30 Dec 2013 05:04 PM
    Hi again, Yes, it's strange. I am able to run it with no problem in Ubuntu 12 with "convert" version 6.7.7 Try one more thing, though I'm not sure it will make a difference, but try calling it in this way: spawn, '/opt/local/bin/convert testconvert.ps testconvert.png' What Linux flavour are you using? fernando

    Deleted User



    New Member


    Posts:14
    New Member


    --
    31 Dec 2013 06:56 AM
    Good morning, Fernando. Yes, it is peculiar. I'm using whatever flavor of UNIX is built into MacOSX 10.8 (Mountain Lion). I believe its based on BSD and the Kernel is Darwin 12.5.0. Based on exchanges I've had on the Google IDL group, this problem seems to affect Macs and not PCs. Barry

    Deleted User



    New Member


    Posts:
    New Member


    --
    31 Dec 2013 11:47 AM
    Hi Barry, Let me check in our Mac system. Cheers! fernando

    Deleted User



    New Member


    Posts:
    New Member


    --
    31 Dec 2013 12:32 PM
    Hi Barry, I have here a Mac 10.8.5 as well, I have installed "convert" from ImageMagic, version 6.8.7 and this is what I'm getting: IDL> p=plot(/test) % Loaded DLM: PNG. IDL> p.save, 'test.ps' IDL> spawn, 'convert test.ps test.png' convert: Postscript delegate failed `test.ps': No such file or directory @ error/ps.c/ReadPSImage/837. convert: no images defined `test.png' @ error/convert.c/ConvertImageCommand/3145. And then from the terminal command line I also get the error: $ convert test.ps test.png convert: Postscript delegate failed `test.ps': No such file or directory @ error/ps.c/ReadPSImage/837. convert: no images defined `test.png' @ error/convert.c/ConvertImageCommand/3145. So, this is slightly different to what you are seeing I think. In my case, I think "convert" for Mac doesn't like something from the postscript IDL has created. I tried using a convertion from gif to png for example, and that works fine from inside IDL. I'm not sure what to think. Fernando

    Deleted User



    New Member


    Posts:14
    New Member


    --
    31 Dec 2013 02:10 PM
    Hi Fernando - I had not thought about generating a GIF and then converting it to PNG. That works fine for me too. I think this gives me another clue in trying to figure out what is wrong. I'll work on it some more and let you know if I find anything useful. Thanks again and Happy New Year. Barry

    Deleted User



    New Member


    Posts:
    New Member


    --
    31 Dec 2013 03:26 PM
    Hi Barry, Please, let us know what you find out. I can discuss this with my colleagues as well. Were all the ps files generated by IDL? In any case, it's strange that for you it's working fine outside IDL, while for me the same error message happens even calling convert outside IDL. Anyway, happy new year to you too! Cheers, fernando

    Deleted User



    New Member


    Posts:14
    New Member


    --
    01 Jan 2014 02:20 PM
    Hi Fernando - just a quick note to let you know that yes, the PS files I was using were generated by IDL. I agree that it is strange that the convert works fine from the shell but not from within IDL (at least when going from ps to some other format). Barry

    Deleted User



    New Member


    Posts:14
    New Member


    --
    24 Feb 2014 12:34 PM
    Hi Fernando. I haven't solved this problem yet. I was wondering if you had any suggestions for more troubleshooting? This seems to be an issue with the way IDL communicates with Imagemagik/ghostscript that is peculiar to the Macintosh. Barry

    Deleted User



    New Member


    Posts:14
    New Member


    --
    27 Feb 2014 04:33 PM
    Still trying to solve this problem. What does the IDL 'spawn' command do exactly? We have the following facts: 1. IDL8.2.3 running on a Macintosh under OSX10.8.5 2. Imagemagick version 6.8.8-3 Q16 x86_64 3. ghostscript version 9.10 4. When invoked from the shell (bash), the command 'convert test.ps test.png' works perfectly. The ps file is converted to png. 5. When invoked from within IDL by using the command SPAWN, 'convert test.ps test.png' fails with the error message included in the original post. 6. The command SPAWN, 'which convert' points to the correct location (in this case /opt/local/bin/convert). 7. The results from within IDL are the same (failure) if the full path for the convert command is given. 8. The results from within IDL also fail if the command is SPAWN, ['convert', 'test.ps', 'test.png'], /NOSHELL If the SPAWN commands just passes the argument to the OS to create a daughter process, why does this particular command fail?

    Deleted User



    New Member


    Posts:
    New Member


    --
    27 Feb 2014 04:40 PM
    Hi Barry, Let me discuss this with some people and I will be back as soon as possible. Thanks, Fernando

    Deleted User



    New Member


    Posts:
    New Member


    --
    28 Feb 2014 09:30 AM
    Hi Barry, The idea is the following. When you use SPAWN, IDL creates a new process that inherit the IDL session environment variables. This means that what it could be happening is that "convert" is picking up IDL's version of zlib, which it seems as it doesn't work well with ImageMagick. The environment variable is DYLD_LIBRARY_PATH, so the idea is to try to point that variable to the right zlib that it's use by "convert". Maybe you could try setting that variable before calling convert, and then spawning "convert". Then of course you will need to set the variable back to the original value so IDL will continue working correctly. Let me know how that goes. Cheers, Fernando
    You are not authorized to post a reply.