{ "info": { "author": "Lilo Huang", "author_email": "kuso.cc@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# PyTurboJPEG\nA Python wrapper of libjpeg-turbo for decoding and encoding JPEG image.\n\n## Prerequisites\n- [libjpeg-turbo](https://github.com/libjpeg-turbo/libjpeg-turbo/releases)\n- [numpy](https://github.com/numpy/numpy)\n\n## Example\n\n```python\nimport cv2\nfrom turbojpeg import TurboJPEG, TJPF_GRAY, TJSAMP_GRAY, TJFLAG_PROGRESSIVE\n\n# specifying library path explicitly\n# jpeg = TurboJPEG(r'D:\\turbojpeg.dll')\n# jpeg = TurboJPEG('/usr/lib64/libturbojpeg.so')\n# jpeg = TurboJPEG('/usr/local/lib/libturbojpeg.dylib')\n\n# using default library installation\njpeg = TurboJPEG()\n\n# decoding input.jpg to BGR array\nin_file = open('input.jpg', 'rb')\nbgr_array = jpeg.decode(in_file.read())\nin_file.close()\ncv2.imshow('bgr_array', bgr_array)\ncv2.waitKey(0)\n\n# direct rescaling 1/2 while decoding input.jpg to BGR array\nin_file = open('input.jpg', 'rb')\nbgr_array_half = jpeg.decode(in_file.read(), scaling_factor=(1, 2))\nin_file.close()\ncv2.imshow('bgr_array_half', bgr_array_half)\ncv2.waitKey(0)\n\n# decoding JPEG image properties\nin_file = open('input.jpg', 'rb')\n(width, height, jpeg_subsample, jpeg_colorspace) = jpeg.decode_header(in_file.read())\nin_file.close()\n\n# encoding BGR array to output.jpg with default settings.\nout_file = open('output.jpg', 'wb')\nout_file.write(jpeg.encode(bgr_array))\nout_file.close()\n\n# encoding BGR array to output.jpg with TJSAMP_GRAY subsample.\nout_file = open('output_gray.jpg', 'wb')\nout_file.write(jpeg.encode(bgr_array, jpeg_subsample=TJSAMP_GRAY))\nout_file.close()\n\n# encoding BGR array to output.jpg with quality level 50. \nout_file = open('output_quality_50.jpg', 'wb')\nout_file.write(jpeg.encode(bgr_array, quality=50))\nout_file.close()\n\n# encoding BGR array to output.jpg with quality level 100 and progressive entropy coding.\nout_file = open('output_quality_100_progressive.jpg', 'wb')\nout_file.write(jpeg.encode(bgr_array, quality=100, flags=TJFLAG_PROGRESSIVE))\nout_file.close()\n\n# decoding input.jpg to grayscale array\nin_file = open('input.jpg', 'rb')\ngray_array = jpeg.decode(in_file.read(), pixel_format=TJPF_GRAY)\nin_file.close()\ncv2.imshow('gray_array', gray_array)\ncv2.waitKey(0)\n```\n\n## Installation\n\n### macOS\n- brew install jpeg-turbo\n- pip install -U git+git://github.com/lilohuang/PyTurboJPEG.git\n\n### Windows \n- Download [libjpeg-turbo official installer](https://sourceforge.net/projects/libjpeg-turbo/files) \n- pip install -U git+git://github.com/lilohuang/PyTurboJPEG.git\n\n### Linux\n- Download [libjpeg-turbo.repo](https://libjpeg-turbo.org/pmwiki/uploads/Downloads/libjpeg-turbo.repo) to /etc/yum.repos.d/\n- sudo yum install libjpeg-turbo-official\n- pip install -U git+git://github.com/lilohuang/PyTurboJPEG.git\n\n\n## Benchmark \n\n### macOS\n- macOS Sierra 10.12.6\n- Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz\n- opencv-python 3.4.0.12 (pre-built)\n- turbo-jpeg 1.5.3 (pre-built)\n\n| Function | Wall-clock time |\n| ----------------------|-----------------|\n| cv2.imdecode() \u00a0 \u00a0 \u00a0 | 0.528 sec \u00a0 |\n| TurboJPEG.decode() | 0.191 sec |\n| cv2.imencode() \u00a0 \u00a0 \u00a0 | 0.875 sec \u00a0 |\n| TurboJPEG.encode() | 0.176 sec |\n\n### Windows \n- Windows 7 Ultimate 64-bit\n- Intel(R) Xeon(R) E3-1276 v3 CPU @ 3.60 GHz\n- opencv-python 3.4.0.12 (pre-built)\n- turbo-jpeg 1.5.3 (pre-built)\n\n| Function | Wall-clock time |\n| ----------------------|-----------------|\n| cv2.imdecode() \u00a0 \u00a0 \u00a0 | 0.358 sec \u00a0 |\n| TurboJPEG.decode() | 0.135 sec |\n| cv2.imencode() \u00a0 \u00a0 \u00a0 | 0.581 sec \u00a0 |\n| TurboJPEG.encode() | 0.140 sec |", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/lilohuang/PyTurboJPEG", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "PyTurboJPEG", "package_url": "https://pypi.org/project/PyTurboJPEG/", "platform": "", "project_url": "https://pypi.org/project/PyTurboJPEG/", "project_urls": { "Homepage": "https://github.com/lilohuang/PyTurboJPEG" }, "release_url": "https://pypi.org/project/PyTurboJPEG/1.3.1/", "requires_dist": null, "requires_python": "", "summary": "A Python wrapper of libjpeg-turbo for decoding and encoding JPEG image.", "version": "1.3.1" }, "last_serial": 6001667, "releases": { "1.1.5": [ { "comment_text": "", "digests": { "md5": "bdd17f5d66979892420479f779f90c35", "sha256": "f7661878dcca56470b3ff3b961e4d9fef16c99a1d1fa73633b3760c42b5420ae" }, "downloads": -1, "filename": "PyTurboJPEG-1.1.5.tar.gz", "has_sig": false, "md5_digest": "bdd17f5d66979892420479f779f90c35", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4793, "upload_time": "2019-04-29T09:42:11", "url": "https://files.pythonhosted.org/packages/e0/c3/910cc3093c7a7b793eddce268a0fa16aea3e0fdfacab2f71a4a48777f1a0/PyTurboJPEG-1.1.5.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "aecd5cad9c033e564dfa782f14c5794c", "sha256": "1d161eb29a6120d84cbadfb05654ac36da030f5bb5993e68abe9478183c69224" }, "downloads": -1, "filename": "PyTurboJPEG-1.2.0.tar.gz", "has_sig": false, "md5_digest": "aecd5cad9c033e564dfa782f14c5794c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5283, "upload_time": "2019-07-06T08:26:03", "url": "https://files.pythonhosted.org/packages/be/8e/69ec3046d300bb449ac395a4d97bfad94e8e9519622df63454f1cf9bc94c/PyTurboJPEG-1.2.0.tar.gz" } ], "1.3.0": [ { "comment_text": "", "digests": { "md5": "c8b47896425a09d596da5b4f137c533b", "sha256": "19b10798475b5570fd9a66dca64fb0c36ab11965787dc0411d7535ae1f1977ca" }, "downloads": -1, "filename": "PyTurboJPEG-1.3.0.tar.gz", "has_sig": false, "md5_digest": "c8b47896425a09d596da5b4f137c533b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5340, "upload_time": "2019-09-23T12:37:59", "url": "https://files.pythonhosted.org/packages/00/83/6e66fc8250c675544a8352c83dc39c0cb5e39c4e29a86a01263683c2dad8/PyTurboJPEG-1.3.0.tar.gz" } ], "1.3.1": [ { "comment_text": "", "digests": { "md5": "1a286a897f556477071325307ecdf17f", "sha256": "ad88e86160ab92210b59eaeac6ed5041b8b4e4c56cad2c00734a8100911b8de5" }, "downloads": -1, "filename": "PyTurboJPEG-1.3.1.tar.gz", "has_sig": false, "md5_digest": "1a286a897f556477071325307ecdf17f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5337, "upload_time": "2019-10-20T02:27:59", "url": "https://files.pythonhosted.org/packages/c5/40/bc4aede28f6c922bcab9808a80982a69381df6e9b318dfa691fc6fe2eb36/PyTurboJPEG-1.3.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1a286a897f556477071325307ecdf17f", "sha256": "ad88e86160ab92210b59eaeac6ed5041b8b4e4c56cad2c00734a8100911b8de5" }, "downloads": -1, "filename": "PyTurboJPEG-1.3.1.tar.gz", "has_sig": false, "md5_digest": "1a286a897f556477071325307ecdf17f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5337, "upload_time": "2019-10-20T02:27:59", "url": "https://files.pythonhosted.org/packages/c5/40/bc4aede28f6c922bcab9808a80982a69381df6e9b318dfa691fc6fe2eb36/PyTurboJPEG-1.3.1.tar.gz" } ] }