Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fangwei123456/python-jpeg-encoder
create a standardized JPEG file
https://github.com/fangwei123456/python-jpeg-encoder
encode image-processing jpeg python
Last synced: about 1 month ago
JSON representation
create a standardized JPEG file
- Host: GitHub
- URL: https://github.com/fangwei123456/python-jpeg-encoder
- Owner: fangwei123456
- License: mit
- Created: 2019-03-14T07:52:09.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-14T08:33:55.000Z (almost 6 years ago)
- Last Synced: 2024-11-27T23:42:16.092Z (about 1 month ago)
- Topics: encode, image-processing, jpeg, python
- Language: Python
- Homepage:
- Size: 695 KB
- Stars: 45
- Watchers: 1
- Forks: 11
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# python-jpeg-encoder
A jpeg encoder written in python. It can encode a BMP image file to a JPEG file. A jpeg decoder written in python is not needed because the encoder will create a standardized JPEG file, which can be opened with any picture viewer.
### **Usage:**
`python jpegEncoder.py inputBMPFileName outputJPEGFileName quality(from 1 to 100) debugMode(0 or 1)`
Example:
`python ./jpegEncoder.py ./lena.bmp ./output.jpg 95 0`
### **More information:**
If `debugMode` is 1, you will get more details about encoding process.
For example, run `jpegEncoder.py` by:
`python ./jpegEncoder.py ./8x8.bmp ./output.jpg 95 1`
And you will get:
srcImageWidth = 8 srcImageHeight = 8
srcImage info:
added to: 8 8
yImageMatrix:
[[255 255 255 255 255 255 255 255]
[255 255 255 255 255 255 255 255]
[255 255 255 255 255 255 255 255]
[255 255 255 255 255 255 255 255]
[255 255 255 255 255 255 255 255]
[255 255 255 255 255 255 255 255]
[255 255 255 255 255 255 255 255]
[255 255 255 255 255 255 255 255]]
uImageMatrix:
[[128 128 128 128 128 128 128 128]
[128 128 128 128 128 128 128 128]
[128 128 128 128 128 128 128 128]
[128 128 128 128 128 128 128 128]
[128 128 128 128 128 128 128 128]
[128 128 128 128 128 128 128 128]
[128 128 128 128 128 128 128 128]
[128 128 128 128 128 128 128 128]]
vImageMatrix:
[[128 128 128 128 128 128 128 128]
[128 128 128 128 128 128 128 128]
[128 128 128 128 128 128 128 128]
[128 128 128 128 128 128 128 128]
[128 128 128 128 128 128 128 128]
[128 128 128 128 128 128 128 128]
[128 128 128 128 128 128 128 128]
[128 128 128 128 128 128 128 128]]
luminanceQuantTbl:
[[ 2 1 1 2 2 4 5 6]
[ 1 1 1 2 3 6 6 6]
[ 1 1 2 2 4 6 7 6]
[ 1 2 2 3 5 9 8 6]
[ 2 2 4 6 7 11 10 8]
[ 2 4 6 6 8 10 11 9]
[ 5 6 8 9 10 12 12 10]
[ 7 9 10 10 11 10 10 10]]
chrominanceQuantTbl:
[[ 2 2 2 5 10 10 10 10]
[ 2 2 3 7 10 10 10 10]
[ 2 3 6 10 10 10 10 10]
[ 5 7 10 10 10 10 10 10]
[10 10 10 10 10 10 10 10]
[10 10 10 10 10 10 10 10]
[10 10 10 10 10 10 10 10]
[10 10 10 10 10 10 10 10]]
blockSum = 1
block (y,x): 0 0 -> 8 8
yDctMatrix:
[[1024. 0. 0. 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0. 0. 0. 0.]]
uDctMatrix:
[[8. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0.]]
vDctMatrix:
[[8. 0. 0. 0. 0. 0. 0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