java waitfor() never returns when warnings occur

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
tms

java waitfor() never returns when warnings occur

Post by tms »

I've found that when I shell out from java to execute imageMagick convert.exe, it will never return a 'process complete' state to the java Process.waitfor() method whenever warnings occur.

For example, if I exec the command line:

Code: Select all

"c:\Program Files\ImageMagick\convert.exe" 
  +matte -gravity Center -thumbnail 100x100 -density 72 -background white -extent 100x100 
  "C:\ingest\VRUpload\ag-obj-241-014-mas.tif" 
  "C:\ingest\thumbs\ag-obj-241-014-mas.jpg"
I'll get:

Code: Select all

convert.exe: C:\ingest\VRUpload\ag-obj-241-014-mas.tif: wrong data type 7 for "XMLPacket"; tag ignored. `TIFFReadDirectory' @ tiff.c
/TIFFWarnings/546.
convert.exe: C:\ingest\VRUpload\ag-obj-241-014-mas.tif: wrong data type 7 for "RichTIFFIPTC"; tag ignored. `TIFFReadDirectory' @ tif
f.c/TIFFWarnings/546.
convert.exe: C:\ingest\VRUpload\ag-obj-241-014-mas.tif: wrong data type 7 for "Photoshop"; tag ignored. `TIFFReadDirectory' @ tiff.c
/TIFFWarnings/546.
convert.exe: C:\ingest\VRUpload\ag-obj-241-014-mas.tif: unknown field with tag 37724 (0x935c) encountered. `TIFFReadDirectory' @ tif
f.c/TIFFWarnings/546.
Which are valid warnings for that particular file. The problem is that if I shell out of java with that same command it will just hang, even though the process has actually completed. I.e. it's as though convert.exe is still running (as far as java is concerned).

For what it's worth, my java looks like:

Code: Select all

    Process proc = null;
    try 
    {
      proc = Runtime.getRuntime().exec(command);
    } 
    catch (IOException e) 
    {
      throw new MediaToolsException("IOException while trying to execute: " + command + "\n"+e.getMessage());
    }

    while (true) 
    {
      try 
      {
        proc.waitFor();   // This line just hangs forever when those warnings occur.
        break;
      } 
      catch (java.lang.InterruptedException e) 
      {
        throw new MediaToolsException("IngestUtils.exec: Process interrupted while trying to execute: " + command);
      }
    }
What I've discovered as a workaround is that by adding the -quiet switch the problem goes away. The process returns normally and everything works properly.

So I guess my question is - is this a bug? Frankly I'm more concerned about the java side than imageMagick, but I'm wondering what the process could be doing to cause this behavior, and whether there's a way to detect this?
Thanks in advance,
Tim
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: java waitfor() never returns when warnings occur

Post by anthony »

I have no idea why java is hanging.

However you should read your image BEFORE trying to use processing options on it.
Your using a legacy option handling capability that may disappear at some point.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
tms

Re: java waitfor() never returns when warnings occur

Post by tms »

anthony wrote:However you should read your image BEFORE trying to use processing options on it.
Your using a legacy option handling capability that may disappear at some point.
Sorry, I have no clue what you're saying. I'm far from an IM expert. What does "read your image" mean? Which option is deprecated, and what should I use instead?
Thanks,
Tim
Post Reply