java - 使用 JMagick 调整图像大小

标签 java dll imagemagick jmagick

我想使用 JMagick 调整图像大小。

import magick.ImageInfo;
import magick.MagickImage;

public class JMagicInfoa {
    public static void main(String args[]){
    try{
        ImageInfo origInfo = new ImageInfo(args[0]); //load image info
        MagickImage image = new MagickImage(origInfo); 
        image = image.scaleImage(1000, 1000);
        image.setFileName(args[1]); //give new location
        image.writeImage(origInfo);
        }catch (Exception e) {
            e.printStackTrace();
        }

    }
}

我遇到以下错误:

Exception in thread "main" java.lang.UnsatisfiedLinkError: D:\Program Files\ImageMagick-6.8.6-Q16\jmagick.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1778)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1703)
    at java.lang.Runtime.loadLibrary0(Runtime.java:823)
    at java.lang.System.loadLibrary(System.java:1030)
    at magick.MagickLoader.<clinit>(MagickLoader.java:13)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.lang.Class.newInstance0(Class.java:355)
    at java.lang.Class.newInstance(Class.java:308)
    at magick.Magick.<clinit>(Magick.java:21)
    at JMagicInfo.JMagicInfoa.main(JMagicInfoa.java:10)

我搜索了 64 位 JMagick.dll,但在任何地方都找不到。

是否有任何替代方案可以在 64 位计算机上运行此程序。

编辑

我将 64 位 JDK 替换为 32 位,现在遇到以下错误:

java.lang.UnsatisfiedLinkError: D:\Program Files\ImageMagick-6.8.6-Q16\jmagick.dll: %1 is not a valid Win32 application
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(Unknown Source)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)

第二次编辑

以上代码在 32 位机器上按预期工作。它不仅仅适用于 64 位机器。

请提出建议

最佳答案

您可以尝试使用32位版本的JDK。这对我有用

关于java - 使用 JMagick 调整图像大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18403559/

相关文章:

java - 在Linux服务器上加载OpenCV库时出现问题: file too short

java - 继承 ParseObject 子类 (Android)

c++ - 延迟加载的 DLL 在内存中的加载距离彼此太远

php - PHP 中的 Imagemagick 特定 webp 调用

java - Spring参数验证注解不验证

java - 多线程程序中出现意外结果

c++ - Boost ini_parser - 单例 DLL 问题

c++ - 为什么 DLL 没有复制到输出目录? C++ Visual Studio

php - fatal error : Class 'imagick' not found

ImageMagick:运行转换时出错:转换:无法读取字体