Page 1 of 1

Compare result text file size is huge

Posted: 2018-07-15T23:36:03-07:00
by philhung
Hi all,

I am new to ImageMagicK

I use the below command to compare 2 pdf files and generate the difference to the text file.

Code: Select all

convert c:\QG1.pdf null: c:\QG2.pdf -compose Difference -layers composite c:\diff.txt
but the output text file size is very large, sometimes over 200m bytes.
I look into the text file, the text file not only contain the differences, but the pixels with no difference.
I think this is the reason why the output file size is so large...

is it possible that the output text file with difference only, or any other smart way using ImageMagicK to compare 2 pdf to text file??

thanks a lot in advance!!!

Re: Compare result text file size is huge

Posted: 2018-07-16T05:01:28-07:00
by snibgo
Writing to "txt:" output always gives all of the pixels. In your case, the black pixels are the same in both inputs, so you can process the output in an external filter (such a grep, or Windows findstr) to remove those pixels.

Another option is to make black pixels transparent ("-transparent black"), then to output to "sparse-color:" which doesn't output transparent pixels.

Re: Compare result text file size is huge

Posted: 2018-07-16T19:54:24-07:00
by philhung
thanks for your help.

I tried to output the difference to image file

Code: Select all

convert c:\QG1.pdf null: c:\QG2.pdf -compose Difference -layers composite c:\diff.png
and then convert that image file to txt file with ("-transparent black") and ("sparse-color:")

Code: Select all

convert c:\diff.png -transparent white sparse-color c:\diff.txt
the below are some lines of the output files

Code: Select all

406,0: (65535,65535,65535,0)  #FFFFFFFFFFFF0000  srgba(255,255,255,0)
407,0: (65535,65535,65535,0)  #FFFFFFFFFFFF0000  srgba(255,255,255,0)
408,0: (65535,65535,65535,0)  #FFFFFFFFFFFF0000  srgba(255,255,255,0)
409,0: (65535,65535,65535,0)  #FFFFFFFFFFFF0000  srgba(255,255,255,0)
410,0: (65535,65535,65535,0)  #FFFFFFFFFFFF0000  srgba(255,255,255,0)
411,0: (65535,65535,65535,0)  #FFFFFFFFFFFF0000  srgba(255,255,255,0)
412,0: (65535,65535,65535,0)  #FFFFFFFFFFFF0000  srgba(255,255,255,0)
413,0: (65535,65535,65535,0)  #FFFFFFFFFFFF0000  srgba(255,255,255,0)
414,0: (65535,65535,65535,0)  #FFFFFFFFFFFF0000  srgba(255,255,255,0)
415,0: (65535,65535,65535,0)  #FFFFFFFFFFFF0000  srgba(255,255,255,0)
I think I make something wrong when using ("sparse-color:")...
thanks again for your help in advance, thanks!!

Re: Compare result text file size is huge

Posted: 2018-07-16T20:20:19-07:00
by fmw42
You are confusing -sparse-color with sparse-color:

See http://www.imagemagick.org/Usage/files/#sparse-color

Try:

Code: Select all

convert c:\diff.png -transparent white sparse-color: > c:\diff.txt
But that will give one long string.

In unix, you can pipe to tr to change the space to a new line, for example:

Code: Select all

convert logo: -transparent white sparse-color: | tr " " "\n" > diff.txt
I do not know if Windows has an equivalent.

Re: Compare result text file size is huge

Posted: 2018-07-17T19:05:39-07:00
by philhung
many thanks for support, it works perfectly, thanks again

Re: Compare result text file size is huge

Posted: 2018-07-20T02:37:56-07:00
by PhillpZeng
convert c:\diff.png -transparent white sparse-color: > c:\diff.txt
this command did not work to my PNG files, I just get an empty txt file.
is there anything else should I pay attentions?

Re: Compare result text file size is huge

Posted: 2018-07-20T03:06:41-07:00
by snibgo
If the input c:\diff.png is entirely white then the output should be empty.

Do you get any error message?

For more help, please provide a link to the input, and tell us what version of IM you are using, on what platform.

Re: Compare result text file size is huge

Posted: 2018-07-25T23:28:54-07:00
by PhillpZeng
it is not entirely white, just an extra word in png.

the command as this:

Code: Select all

Compare -compose src A.pdf B.pdf AB.png

Code: Select all

convert AB.png -transparent white sparse-color: > AB.txt
is there any problem?

thank you.

Re: Compare result text file size is huge

Posted: 2018-07-26T08:51:17-07:00
by fmw42
How can we comment about your command without having your two input images to see what is going on.

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