I'm getting the following error message when running my code from a Spring WebMvcTest. The code works correctly when called from my application, just not in the test. Code is:
privatebyte[]createThumbnailImage(byte[]imageData,StringimageFormat)throwsImageConversionException{ByteArrayOutputStreamos=newByteArrayOutputStream();try{InputStreamis=newByteArrayInputStream(imageData);IMOperationop=newIMOperation();op.addImage("-");op.thumbnail(THUMBNAIL_SIZE);if(imageFormat.equalsIgnoreCase(PDF_FILE_EXTENSION)){op.background("white");op.alpha("remove");//createPNGimageoutputforPDFfilesop.addImage(PNG_FILE_EXTENSION+":-");}else{op.addImage(imageFormat+":-");}PipepipeIn=newPipe(is,null);PipepipeOut=newPipe(null,os);ConvertCmdconvert=newConvertCmd();convert.setInputProvider(pipeIn);convert.setOutputConsumer(pipeOut);convert.run(op);}catch(IOException|IM4JavaException|InterruptedExceptione){if(e.getMessage().contains("Cannot run program \"convert\"")){Stringmessage="Imagemagick not found or not installed.";LOG.error(message);thrownewImageConversionException(message);}thrownewImageConversionException(e.getMessage());}returnos.toByteArray();}
I can run the same test for an image file (.jpg) and it converts correctly, both in the test and when the application is running. When converting for a PDF the command passed to IM is:
- -thumbnail 255 -background white -alpha remove png:-
The command is the same both when running the application and when calling the same code from a unit test, but in the unit test I get the following exception thrown and error message:
CommandException: magick: no images found for operation-thumbnail' at CLI arg 2`
I have IM and Ghostscript installed locally. Could there be a problem with IM calling Ghostscript, or a Pipe wrapper problem from a unit test? Appreciate any help. Thanks,
Tom
Last edit: Tom 2017-01-25
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm a bit confused by "CommandException: magick". This suggests a new version of IM where all commands like "convert" are symlinks to "magick". Could you please check this? You could try to replace the symlinks with hardlinks. The magick-command behaves differently depending on the name it is called with, but im4java already resolves to the real name while searching for the command so this information gets lost.
Bernhard
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm getting the following error message when running my code from a Spring WebMvcTest. The code works correctly when called from my application, just not in the test. Code is:
I can run the same test for an image file (.jpg) and it converts correctly, both in the test and when the application is running. When converting for a PDF the command passed to IM is:
- -thumbnail 255 -background white -alpha remove png:-
The command is the same both when running the application and when calling the same code from a unit test, but in the unit test I get the following exception thrown and error message:
CommandException: magick: no images found for operation
-thumbnail' at CLI arg 2`I have IM and Ghostscript installed locally. Could there be a problem with IM calling Ghostscript, or a Pipe wrapper problem from a unit test? Appreciate any help. Thanks,
Tom
Last edit: Tom 2017-01-25
I'm a bit confused by "CommandException: magick". This suggests a new version of IM where all commands like "convert" are symlinks to "magick". Could you please check this? You could try to replace the symlinks with hardlinks. The magick-command behaves differently depending on the name it is called with, but im4java already resolves to the real name while searching for the command so this information gets lost.
Bernhard