2014-09-04 7 views
0

IM4Java 라이브러리를 통해 Image Magick을 사용하여 이미지의 크기를 조정하려고합니다.im4java 및 imagemagick - 중력 매개 변수가 작동하지 않는 이유는 무엇입니까?

이미지가 가운데에 있지 않다는 점을 제외하면 잘 작동합니다. 필자는 외부 명령 행을 통해이 같은 명령을 실행했으며 제대로 작동합니다.

아무도 왜 이것이 작동하지 않는지 말할 수 있습니까?

private void convertImage(int width, int height, String source, String dest) 
     throws IOException, IM4JavaException, InterruptedException 
{ 
    // create command 
    ConvertCmd cmd = new ConvertCmd(); 

    // create the operation, add images and operators/options 
    IMOperation op = new IMOperation(); 
    op.addImage(source); 

    op.thumbnail(width, height, ">"); 
    op.extent(width, height); 
    op.gravity("center"); 
    op.background("white"); 

    op.addImage(dest); 
    ProcessStarter.setGlobalSearchPath("/usr/local/bin"); 
    cmd.setOutputConsumer(imageMagickOutputter); 
    cmd.run(op); 

} 

The result of the command with background switched to blue

답변

0

작업 문제의 순서 : 썸네일과 범위 전에 중력 작업을 넣어 :

 IMOperation op = new IMOperation(); 
     op.addImage(sourceFile); 
     op.gravity("center"); 
     op.thumbnail(width, height, '^'); 
     op.extent(width,height); 
     op.addImage(destinationFile); 
+0

멋진 아, 감사합니다! 효과가있었습니다. –