Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7831207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:37:14+00:00 2026-06-02T11:37:14+00:00

I am trying to use IM4J (a Java wrapper for ImageMagick) to create thumbnails

  • 0

I am trying to use IM4J (a Java wrapper for ImageMagick) to create thumbnails of JPEGs and it is my first experience (ever) with both libraries. Please note that this is a hard requirement handed to me by my tech lead (so please don’t suggest to use anything other than an IM4J/ImageMagick) solution – my hands are tied on the technology choice here!

I am getting a FileNotFoundException on the and convert command which tells me I don’t have one of these libraries (or both) setup correctly.

On my computer, here is my directory structure:

C:/
    myApp/
        images/             --> where all of my JPEGs are
        thumbnails/         --> where I want ImageMagick to send the converted thumbnails to
        imageMagickHome/    --> Where I downloaded the DLL to
            ImageMagick-6.7.6-1-Q16-windows-dll.exe
    ...
    

In my Java project, I make sure that the IM4J JAR (im4java-1.2.0.jar) is on the classpath at runtime. Although I am required to use the 1.2.0 version of IM4J, I have the liberty to use any version of ImageMagick that I want. I simply chose this version because it seemed like the most current/stable version for my Windows 7 (32-bit) machine. If I should use a different version, please send me a link to it from the ImageMagick downloads page in your answer!

As for ImageMagick, I just downloaded that EXE from here and placed it in the folder mentioned above – I didn’t do any installation, wizard, MSI, environment variable configuration, etc.

Then, in my Java code:

// In my driver...
File currentFile = new File("C:/myApp/images/test.jpg"); --> exists and is sitting at this location
File thumbFile = new File("C:/myApp/thumbnails/test-thumb.jpg"); --> doesnt exist yet! (destination file)
Thumbnailer myThumbnailer = new Thumbnailer();
myThumbnailer.generateThumbnail(currentFile, thumbFile);

// Then the Thumbnailer:
public class Thumbnailer
{
    // ... omitted for brevity
    
    public void generateThumbnail(File originalFile, File thumbnailFile)
    {
        // Reads appConfig.xml from classpath, validates it against a schema,
        // and reads the contents of an element called <imPath> into this
        // method's return value. See below
        String imPath = getIMPathFromAppConfigFile();
    
        org.im4java.core.IMOperation op = new Operation();
        op.colorspace(this.colorSpace);
        op.addImage(originalFile.getAbsolutePath());
        op.flatten();
        op.addImage(thumbnailFile.getAbsolutePath());
        
        ConvertCmd cmd = new ConvertCmd();
        
        cmd.setSearchPath(imPath);
        
        // This next line is what throws the FileNotFoundException
        cmd.run(op);
    }
}

The section of my appConfig.xml file that contains the imPath:

<imPath>C:/myApp/imageMagickHome</imPath>

Please note – if this appConfig.xml is not well-formed, our schema validator will catch it. Since we are not getting schema validation errors, we can rule this out as a culprit. However, notice my file path delimiters; they are all forward slashes. I did this because I was told that, on Windows systems, the forward slash is treated the same as a *nix backslash, in reference to file paths. Believe it or not, we are developing on Windows
machines, but deploying to linux servers, so this was my solution (again, not my call!).

IM4J even acknowledges that Windows users can have trouble sometimes and explains in this article that Windows developers might have to set an IM4JAVA_TOOLPATH env var to get this library to work. I tried this suggestion, created a new System-wide environmental variable of the same name and set its value to C:\myApp\imageMagickHome. Still no difference. But notice here I am using backslashes. This is because this env var is local to my machine, whereas the appConfig.xml is a config descriptor that gets deployed to the linux servers.

From what I can tell, the culprit is probably one (or more) of the following:

  • I didn’t "install" the ImageMagick EXE correctly and should have used an installer/MSI; or I need to add some other environmental variables for ImageMagick (not IM4J) itself
  • Perhaps I still don’t have IM4J configured correctly and need to add more environmental variables
  • Could be the Windows/*nix "/" vs. "" issue from my appConfig.xml file as mentioned above

I’m also perplexed as to why I’m getting a FileNotFoundException on a file named "convert":

java.io.FileNotFoundException: convert

I assume this is a batch/shell file living somewhere inside the IM4J jar (since the only thing I downloaded for ImageMagick was the EXE). However, if I extract the IM4J jar I only see classes inside of it. I see "script generator" classes, so I assume these kick off before my cmd.run(op) call and create the convert file, and maybe that’s what I’m missing (perhaps I need to manually kick off one of these generators, like CmdScriptGenerator prior to executing my Thumbnailer methods. . Or, maybe my download is incomplete.

Either way, I’m just not versed enough with either library to know where to start.

Thanks for any help with this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:37:16+00:00Added an answer on June 2, 2026 at 11:37 am

    Run the ‘ImageMagick-6.7.6-1-Q16-windows-dll.exe’ installer first to install the imagemagick libraries. Then make sure your environment path includes the location of the installed binaries (‘convert.exe’, ‘mogrify.exe’, etc)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying use a Java Uploader in a ROR app (for its ease
Trying to use this sql statement. The first 2 parts work fine, I am
Anyone know how to create a cvCreateStructuringElementEx using a image? I'm trying use opencv.cv.cvCreateStructuringElementEx()
I'm trying use a UIScrollview inclined 350 degrees, the first thing I thought was
Trying to use Java's regexp I want to match /app, /app/.* , but not
Im trying use a Java annotation in a Groovy class but have trouble to
I was trying use a set of filter functions to run the appropriate routine,
I'm trying use self-signed certificate (c#): X509Certificate2 cert = new X509Certificate2( Server.MapPath(~/App_Data/myhost.pfx), pass); on
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
Hi I'm trying use a datepicker on a field I have. I'm trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.