difference

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
dav1988
Posts: 19
Joined: 2018-01-07T13:18:56-07:00
Authentication code: 1152

difference

Post by dav1988 »

hello,
sometimes it happens that when i compare 2 equal pics (by using compare) the difference is showed with normal colors in the folder. but then, when i click on it and the pic is open, it appears 'transparent' as normal for equal pics.

what does it mean?

ps.it happens when i download the compared pics from imageshack
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: difference

Post by fmw42 »

Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli


For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
dav1988
Posts: 19
Joined: 2018-01-07T13:18:56-07:00
Authentication code: 1152

Re: difference

Post by dav1988 »

hello...
im sorry.

version: imagemagick 6.9.9-33 Q16 x86 2018-01-06

this is the image: http://imagizer.imageshack.us/a/img922/6240/2k3ME2.jpg

if i upload 2 times this pic (but i think others as well) on inageshack, then i download them on my pc and use:
compare pic1.jpg pic2.jpg dpic.jpg

the result is that in the folder i find the difference with normal colors. but then when i click on it and the difference pic get open is appears trasparent as normal
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: difference

Post by fmw42 »

I suggest you not save the output difference image as JPG, since it is a lossy compressed image. Try saving as PNG or TIFF (dpic.png or dpic.tiff).

Are you uploading the image twice? or Uploading it, then downloading it, then uploading it again. Then download the two for the compare? JPG is a lossy format. Each time it is read and then written it loses some quality.

I get

compare -metric rmse 2k3ME2.jpg 2k3ME2.jpg diff.png
0 (0)

with the diff image showing no highlight colors.
dav1988
Posts: 19
Joined: 2018-01-07T13:18:56-07:00
Authentication code: 1152

Re: difference

Post by dav1988 »

to be precise: i have 2 pics that i want to verify if equals (like the pic linked above).pics are uploaded on imageshack

so i download them on my pc and i compare the pics using imagemagick (compare pic1.jpg pic2.jpg dpic.jpg).

Now: i tried to save the difference as PNG and the difference (PNG) appears transparent in the folder . But as i said before, If i save the difference as JPG, it appears with normal colors .but when i click and open, it appears trasparent .

TO be precise:
http://oi67.tinypic.com/i1xym8.jpg

on your left is dpic.jpg and on your right dpic.png

Dpic.jpg appears trasparent if i click and open it , PNG normally trasparent also in the miniature

My question is: are the compared pics equals or not?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: difference

Post by fmw42 »

JPG does not support transparency. So that is why you see normal colors.

If you specify a metric, you will get back a score in addition to the diff images. Most (but not all) metrics return zero if no difference. So for example

compare -metric rmse 2k3ME2.jpg 2k3ME2.jpg diff.png
0 (0)

Provides zero difference.
dav1988
Posts: 19
Joined: 2018-01-07T13:18:56-07:00
Authentication code: 1152

Re: difference

Post by dav1988 »

ehm no it is impossible

i've always saved difference pics as JPG and pics alwars were transparent...

this happens only with these 2 pics downloaded from imageshack (and saved as JPG) . in addition i underline that only miniature is colored: when i open it i see transparent pic

anyway considering that saving difference as jpg there is no problem can i say compared pics are equal?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: difference

Post by fmw42 »

JPG does not support transparency. When you do

compare -metric rmse 2k3ME2.jpg 2k3ME2.jpg diff.jpg
0 (0)

you get a thumbnail without the alpha channel (it has been removed), so it has normal colors. But the image saved (when opened) has the alpha channel flatted into the image so it looks more whitish. There is no actual transparency.

If you save the diff image to PNG Format, it will contain actual transparency data.

The important thing is that there is no (default red) color in the diff image and the score is 0. If that is the case, then the images are identical.

See https://www.imagemagick.org/Usage/compare
dav1988
Posts: 19
Joined: 2018-01-07T13:18:56-07:00
Authentication code: 1152

Re: difference

Post by dav1988 »

i do not understand probably. but look at this:
http://oi67.tinypic.com/2hy8exd.jpg

the transparent pics you see (miniatures) are all differences saved as JPG, and they are transparent in the miniature as well... not only when i open

[cit]
The important thing is that there is no (default red) color in the diff image and the score is 0. If that is the case, then the images are identical.
[/cit]

anyway this is the PNG difference of the pics with colored miniature JPG difference:
http://oi63.tinypic.com/2rdkg7b.jpg

since there is no red,can i say compared pics are equal? how do i check the score?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: difference

Post by fmw42 »

3 of the 4 difference images show no red color, so they would seem to be identical.

To check the score, add -metric XXX to your command right after compare. I usually use -metric rmse. See the link I mentioned above for other metrics (some like NCC will be identical if the score is 1 rather than 0).

The best indicator of difference is the score. I do not use the diff image unless I want to see where they differ.

I am not sure why you sometimes get the flattened transparency in your diff.jpg thumbnail and when it is just removed. But I would not go by the thumbnail. I look at the actual diff image (in png format) and the metric score values.

The command for me show a thumbnail without transparency flattened in it and the image shows the transparency flatted into the image. But neither have transparency. The score is 0, so the images are identical

Code: Select all

compare -metric rmse 2k3ME2.jpg 2k3ME2.jpg diff.jpg
0 (0)

Most of the time I just get the score by

Code: Select all

compare -metric rmse 2k3ME2.jpg 2k3ME2.jpg null:
0 (0)
dav1988
Posts: 19
Joined: 2018-01-07T13:18:56-07:00
Authentication code: 1152

Re: difference

Post by dav1988 »

Hi thank you very much.

ok i see you compared the same image (2k3me2.jpg) but this is one of the 2 images i had to compare.

Anyway i have obteined the score comparing the 2 pics and it is 0 :
http://oi63.tinypic.com/2hdwfi1.jpg

in addition this is the PNG difference:
http://oi63.tinypic.com/2rdkg7b.jpg

so compared pics are equal, correct?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: difference

Post by fmw42 »

Yes, the compare indicated that the two images are identical (equal). The score is 0 and there is no red showing to mark the different areas in the diff image.

The PNG image you have specified is actually jpg. Note the suffix as 2rdkg7b.jpg. So if you really had saved as PNG, then your upload hosting service has changed it to JPG.
dav1988
Posts: 19
Joined: 2018-01-07T13:18:56-07:00
Authentication code: 1152

Re: difference

Post by dav1988 »

hi

yes it is saved on my pc as PNG: http://oi67.tinypic.com/287hjxe.jpg

i guess it is tinypic that convert format.

thank you very much for support
Post Reply