Hello. I have an instance where a specific image file is causing the convert.exe to hang. However when I run the same command through either the command line in Windows, or through a runtime execution inside java, the operation complets successfully.
The below code should indicate, I hope, that I am performing the same operation (in a local environment) between the im4java interface and the command line.
Super weird. I've tried an assortment of different commands in im4java, nothing seems to matter. Even just tried to 'resave' it.
Speaking of resaving. Whenever I modify the image in anyway, even a simple resaving, it then clears up whatever is wrong with the image and the im4java interface deals with it just fine.
Can anyone reproduce the hanging below? We first found this to be happening in our prod environment on a linux box.
Anyone happen to know or have an idea how I could try to detect the problem aspect(s) of this image before I send it to image magik through im4java? That way we dont have hanging threads out there?
EDIT :: THE ATTACHMENT WILL NOT WORK FOR THE EXAMPLE. It downloads much smaller than the original file, and falls into the "resaved" category and thus works inside im4java.
I downloaded the image from the link above however and that did cause the hanging still
So I am continuing to dig deeper, decided to use the Info Object to investigate the bad image, and a good image (copy of bad)'s differences.
StringincomingFileBad="C:\\WorkStuff\\badOriginal444.jpeg";StringincomingFileGood="C:\\WorkStuff\\badRandomProp.jpeg";StringmimeType="image/jpg";StringenginePath="C:\\Program Files\\ImageMagick-7.0.5-Q16";InfoimageInfoBad=null;InfoimageInfoGood=null;try{imageInfoBad=newInfo(incomingFileBad);imageInfoGood=newInfo(incomingFileGood);}catch(InfoExceptione){// TODO Auto-generated catch blocke.printStackTrace();}if(imageInfoBad!=null){List<String>listOfDiffs=newArrayList<String>();booleanfound=false;Enumeration<String>badNames=imageInfoBad.getPropertyNames();intbadNamesCounter=0,goodNamesCounter=0;while(badNames.hasMoreElements()){StringbadFileProperty=badNames.nextElement();goodNamesCounter=0;badNamesCounter++;Enumeration<String>goodNames=imageInfoGood.getPropertyNames();while(goodNames.hasMoreElements()){StringgoodFileProperty=goodNames.nextElement();goodNamesCounter++;if(goodFileProperty.equals(badFileProperty)){found=true;}}if(!found){listOfDiffs.add(badFileProperty);}found=false;}System.out.println("There were "+badNamesCounter+" bad image properties");System.out.println("There were "+goodNamesCounter+" good image properties");System.out.println(listOfDiffs.size()+" differences in good/bad properties");if(listOfDiffs.size()>0){for(Stringentry:listOfDiffs){System.out.println("Differing Property: "+entry);}}else{System.out.println("No differing properties...");}}
That produces the following output:
We're going to get the image info. For two images.
Pause
There were 151 bad image properties
There were 155 good image properties
There were 1 differences in good/bad properties
Differing Property: Properties:exif:Artist:exif:Copyright:exif:Flash
Now the difference betweent he two images is one is the bad image and one is that same image simply resaved (meaning It'll work)
So digging deeper here, it looks like perhaps that property causing image magik to get mad...
Last edit: Eric Manzitti 2017-09-21
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
this is indeed strange. My first try would be to add an error-consumer. This might be the cause of the hang if the internal buffer for the stderr is not cleared. The output might also give some additional insights. This does not deal with the root-cause of course.
Bernhard
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So we kept digging deeper and a coworker found that if she did the following, it worked.
ConvertCmdcmd=newConvertCmd();StringenginePath="C:\\Program Files\\ImageMagick-7.0.5-Q16";// create the operation, add images and operators/optionsIMOperationop=newIMOperation();op.addImage("C:\\WorkStuff\\badOriginal.jpeg");op.resize(800,600);op.addImage("C:\\WorkStuff\\fixedHappy2.jpg");// execute the operationcmd.setSearchPath(enginePath);cmd.run(op);
Moving one step at a time towards the broken code. We found it was the pipeIn that caused the problem.
Bernie (lol, hehe) ~ I think I'll go ahead and perhaps try to dig into that errorConsumer. I can't let that become production code, but if it'll help the open source, I'll dig into it and try to get you some more info.
As currently our solution is to modify the code to not use the pipe input. We don't seem to have a use case for why the Pipe object was used and so long as it tests fine without using the pipe, we're going that route.
<3 im4java and thanks for the reply.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello. I have an instance where a specific image file is causing the convert.exe to hang. However when I run the same command through either the command line in Windows, or through a runtime execution inside java, the operation complets successfully.
The below code should indicate, I hope, that I am performing the same operation (in a local environment) between the im4java interface and the command line.
Super weird. I've tried an assortment of different commands in im4java, nothing seems to matter. Even just tried to 'resave' it.
Speaking of resaving. Whenever I modify the image in anyway, even a simple resaving, it then clears up whatever is wrong with the image and the im4java interface deals with it just fine.
Can anyone reproduce the hanging below? We first found this to be happening in our prod environment on a linux box.
Anyone happen to know or have an idea how I could try to detect the problem aspect(s) of this image before I send it to image magik through im4java? That way we dont have hanging threads out there?
Oh sorry, here is the image file in question.
And a link to it:
https://drive.google.com/open?id=0B-9pALoPVAUeMmU1RWdpdVJvdkE
EDIT :: THE ATTACHMENT WILL NOT WORK FOR THE EXAMPLE. It downloads much smaller than the original file, and falls into the "resaved" category and thus works inside im4java.
I downloaded the image from the link above however and that did cause the hanging still
Last edit: Eric Manzitti 2017-09-21
So I am continuing to dig deeper, decided to use the Info Object to investigate the bad image, and a good image (copy of bad)'s differences.
That produces the following output:
Now the difference betweent he two images is one is the bad image and one is that same image simply resaved (meaning It'll work)
So digging deeper here, it looks like perhaps that property causing image magik to get mad...
Last edit: Eric Manzitti 2017-09-21
Hi Eric,
this is indeed strange. My first try would be to add an error-consumer. This might be the cause of the hang if the internal buffer for the stderr is not cleared. The output might also give some additional insights. This does not deal with the root-cause of course.
Bernhard
Hi Bernard,
Thanks for the quick reply.
So we kept digging deeper and a coworker found that if she did the following, it worked.
Moving one step at a time towards the broken code. We found it was the pipeIn that caused the problem.
Bernie (lol, hehe) ~ I think I'll go ahead and perhaps try to dig into that errorConsumer. I can't let that become production code, but if it'll help the open source, I'll dig into it and try to get you some more info.
As currently our solution is to modify the code to not use the pipe input. We don't seem to have a use case for why the Pipe object was used and so long as it tests fine without using the pipe, we're going that route.
<3 im4java and thanks for the reply.