gpt4 book ai didi

java - azure : Image Magick gives 0kb output?

转载 作者:行者123 更新时间:2023-11-30 07:33:10 25 4
gpt4 key购买 nike

我已将 Image magick 与 Java WebApp 集成,并将其部署在 Azure 应用服务上。在 azure 上,我得到 0kb 作为图像的输出图像,而同一图像在我的本地计算机上可以很好地转换。我正在使用 im4java 与 Image Magick 集成。下面是代码:

public void compressImage(String imageSource, String destinationPath) throws IOException, InterruptedException,
IM4JavaException {
ConvertCmd cmd = getCommand();
// create the operation, add images and operators/options
IMOperation op = new IMOperation();
op.strip();
op.interlace();
op.addRawArgs(compressionRawArguments);
op.gaussianBlur(compressionGaussianBlur);
op.quality(compressedImageQuality);
op.addImage(imageSource); // source file
op.addImage(destinationPath); // destination file
// execute the operation

cmd.run(op);
}

imageSource 和destination 都是使用java 创建的临时文件。我已检查 imageSource 文件的大小是否正确,但运行此代码后,目标文件始终为 0 Kb。

请告诉我我做错了什么?

最佳答案

回答我自己的问题,以便对可能面临此问题的其他开发人员有所帮助。

Azure 应用服务通常具有 Windows Server VM。您可以在Web容器日志中检查服务器的操作系统。

Image Magick for windows does not allow conversion of remote http image urls while for Unix System, it allows so. My Local machine is MAC So it was working correctly on my local system.

我找到的这个问题的2个解决方案:

  1. 要么使用 Azure 上的 Linux VM

  2. 在您的应用程序中,将图像 URL 下载到临时文件并将该临时文件的绝对路径提供给 image magick转换。

我都尝试过并且都有效。

关于java - azure : Image Magick gives 0kb output?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35772999/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com