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!