about image compression
I have this question about image开发者_如何转开发 compression:
can we compress a series of images such that the next image will only contain the changes from the previous image and so on and so forth ? I was looking for something on the iOS and PC.
any ideas ? (in other words, whats the best way to compress photos for iOS ?)
Thanks.
I understand from the question that you meant every single images have exactly same resolution. If so, consider this algorithm:
- Divide every images into fixed blocks (say 8x8).
- For each block, compare it with previous image's block. Comparison can be pixel-perfect or lossy.
- Encode a flag to indicate block equality (or similarity).
- If there is a mismatch, output that block.
If you have enough room in mobile environment, you can further improve compression by implementing these features:
- Use a proper bit-wise range coder as entropy coder.
- Build a model to handle pixel neighbor-hood. As a naive approach, you can have a look at PNG's filters.
- Use quad-tree or similar structures to implement adaptive block size.
- DO NOT try to model low-bits. They are highly incompressible.
Give the image some bash love.
"sips -s formatOptions 60 image/path" for image/path, you can also just drag the image in.
you can also try to resize the image to save speed
"sips -Z 800 image/path"
this code will keep the aspect ratio
if you want to select all jpg you can write it like this
"sips -Z 800 *.jpg"
its case sensitive so you check if its jpg or JPG.
精彩评论