문제

The original image: http://www.tiaoyue.com/img/_test/original.jpg (2,457 bytes)

Try to get a thumbnail by ImageMagick:

convert \
   http://www.tiaoyue.com/img/_test/original.jpg \
  -thumbnail 200x200\> \
   SecondaryCompression.jpg

Or in Windows:

convert ^
   http://www.tiaoyue.com/img/_test/original.jpg ^
  -thumbnail 200x200^> ^
   SecondaryCompression.jpg

Get the file: SecondaryCompression.jpg (2,452 bytes)

Can I get the target file (SecondaryCompression.jpg) without secondary compression, only copy of original image? (2,457 bytes of the image)

Reference:

도움이 되었습니까?

해결책

The real problem with your 'convert' command is not that the file undergoes a 'secondary compression' as you called it.

The real problem is that some of the pixels get their color values changes very slightly (which in turn does allow a better or, maybe even worse, compression result for the total file).

So you should investigate how you can prevent the color changes first!

To document + verify the color changes for each single pixel, run these commands:

convert  http://www.tiaoyue.com/img/_test/original.jpg  original.txt
convert  SecondaryCompression.jpg                       SecondaryCompression.txt
sdiff -sbB  SecondaryCompression.txt  original.txt

Hint: The TXT output format of convert is a textual representation of the coordinate position of each pixel and its respective color values (these values are given in 3 different ways: decimal RGB (or CMYK) values, hex RGB (or CMYK) values, human readable color names (when possible). If you see the format once, you'll understand it immediately.

One can establish that in total 1415 pixels have changed color values, out of a total of 7500 pixels. That's 18.86% of pixels changed.

To create a visual representation for the pixel differences, run:

compare  original.jpg  SecondaryCompression.jpg                delta1.jpg
compare  original.jpg  SecondaryCompression.jpg  -compose src  delta2.jpg

delta1.jpg    delta2.jpg    original.jpg    SecondaryCompression.jpg

The first image (delta1.jpg, far left) paints those pixels in red which have different color values, using the original.jpg as a light-gray background image.

The second image (delta2.jpg, second from left) paints only pixels in red which have different colors, and paints identical color values as white pixels.

The third image (second from right) is your original JPEG. The fourth one (far right) is your 'unaltered' thumbnail (in reality with some subtle changes for some pixels).

I've no time right now to investigate the reason for the slight color changes (and can't give a reason out of the top of my head), but will maybe return later to this topic.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top