We help IT Professionals succeed at work.
Get Started

imagemagick convert identical image with different name

765 Views
Last Modified: 2013-11-08
I'm trying to use imagemagick to convert images generated on the fly with random names. The chances are that the newly generated image might be identical to previous generated image but with different file name.  For example, I got two original images which are identical (I've used java's bytearray to test):
image1.jpg
image2.jpg

When I used convert -density 100 to convert the image,
convert -density 100 image1.jpg image1.png
convert -density 100 image2.jpg image2.png

 I would expect the converted images (image1.png and image2.pgn) should be the same. But when I use java's bytearray to test, they turn out to be different.

File file = new File("c:/image1.png");
        if (file.exists()) {
        try {
          InputStream is = new FileInputStream(file);
          byte[] fileBytes1 = new byte[is.available()];
          is.read(fileBytes1);
          is.close();
         
          file = new File("c:/image2.png");
          is = new FileInputStream(file);
          byte[] fileBytes2 = new byte[is.available()];
          is.read(fileBytes2);
          is.close();
                   
          boolean blnResult = Arrays.equals(fileBytes1, fileBytes2);
          System.out.println("Are two byte arrays equal ? : " + blnResult);

How can ImageMagick convert two identical files with different filenames to the same image?

Thanks!
         
Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE