{"id":31733955,"url":"https://github.com/ilyakurdyukov/jpeg-quantsmooth","last_synced_at":"2025-10-09T08:59:55.417Z","repository":{"id":43986263,"uuid":"232038116","full_name":"ilyakurdyukov/jpeg-quantsmooth","owner":"ilyakurdyukov","description":"JPEG artifacts removal based on quantization coefficients.","archived":false,"fork":false,"pushed_at":"2024-12-16T13:22:54.000Z","size":579,"stargazers_count":460,"open_issues_count":5,"forks_count":24,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-12-16T14:29:46.605Z","etag":null,"topics":["artifact-removal","jpeg","libjpeg","simd","web-assembly"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ilyakurdyukov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-06T06:26:15.000Z","updated_at":"2024-12-16T13:22:58.000Z","dependencies_parsed_at":"2023-01-29T01:30:49.493Z","dependency_job_id":"c0e00131-2534-469f-a7e0-581efe6960b4","html_url":"https://github.com/ilyakurdyukov/jpeg-quantsmooth","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/ilyakurdyukov/jpeg-quantsmooth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilyakurdyukov%2Fjpeg-quantsmooth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilyakurdyukov%2Fjpeg-quantsmooth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilyakurdyukov%2Fjpeg-quantsmooth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilyakurdyukov%2Fjpeg-quantsmooth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ilyakurdyukov","download_url":"https://codeload.github.com/ilyakurdyukov/jpeg-quantsmooth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilyakurdyukov%2Fjpeg-quantsmooth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001044,"owners_count":26082993,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artifact-removal","jpeg","libjpeg","simd","web-assembly"],"created_at":"2025-10-09T08:59:54.305Z","updated_at":"2025-10-09T08:59:55.408Z","avatar_url":"https://github.com/ilyakurdyukov.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JPEG Quant Smooth\n\nThis program tries to recover the lost precision of DCT coefficients based on a quantization table from a JPEG image. The result is saved as a JPEG image with quantization set to 1 (like a JPEG saved at 100% quality).\n\nYou may not notice jpeg artifacts on the screen without zooming in, but you may notice them after printing. Also, when editing compressed images, artifacts can accumulate, but if you use this program before editing - the result will be better.\n\n* The original project page is [here](https://github.com/ilyakurdyukov/jpeg-quantsmooth).\n\n* You can save a smoothed image with the original quantization tables, which will result in the same DCT coefficients as in the original image. (Note: chroma will be slightly different if upsampling is used at quality level 6)\n\n* Since this program uses quantization tables to recreate DCT coefficients, applying it to JPEG images that have been re-saved multiple times may not produce good results, as it can recover only from the last JPEG recoding, and not from the previous ones.\n\n## WebAssembly\n\nWeb version available [here](https://ilyakurdyukov.github.io/jpeg-quantsmooth/).\nImages are processed locally on your computer.\nWithout multithreading and SIMD optimizations it runs slower than native code.\n\n- Click the \"Load\" button or drag-n-drop JPEG image into the browser window. After processing is complete, you can save the result by clicking the \"Save\" button. You can edit the *filename* field before saving. The *options* field is passed to the *wasm* code when you initiate a processing by loading a file.\n\n## Usage\n\n`jpegqs [options] input.jpg output.jpg`\n\n## Options\n\n`-q, --quality n` Quality setting (0-6, default is 3)  \n`-n, --niter n` Number of iterations (default is 3)  \n`-t, --threads n` Set the number of CPU threads to use  \n`-o, --optimize` Option for libjpeg to produce smaller output file  \n`-v, --verbose n` Print libjpeg debug output  \n`-i, --info n` Print quantsmooth debug output (default is 15)  \nUse the sum of flags: 0 - silent, 1/2/4 - various information, 8 - processing time, 16 - SIMD type.  \n`-p, --cpu n` Use to lower the SIMD type if CPU detection fails:  \n0 - auto, 1 - scalar, 2 - SSE2, 3 - AVX2, 4 - AVX512.\n(`x86` build selects between modes 1-3, `x86_64` from 2-4)  \n\n- The processing time includes only the smoothing algorithm, jpeg reading and writing time is not included.\n- More iterations can make the result look like CG art, can make the photos look unnatural.\n\nThe quality setting sets a combination of flags for processing:\n\n3. default\n4. adds `DIAGONALS` flag  \nsmoother diagonal edges, ~1.5 times slower\n5. adds `JOINT_YUV` flag  \nchroma channels will depend from luminance, better color consistency\n6. adds `UPSAMPLE_UV` flag  \nnon-blurring chroma upsampling, unlike `fancy upsampling` from *libjpeg*\n\n- levels 0-2 is the same as 4-6, but with `LOW_QUALITY` flag  \n~10 times faster, but the quality is lower  \n`LOW_QUALITY` implies `DIAGONALS` (always set)\n\n## Examples\n\n- Images 3x zoomed.\n\n\u003cp align=\"center\"\u003e\u003cb\u003e\nOriginal images:\u003cbr\u003e\n\u003cimg src=\"https://ilyakurdyukov.github.io/jpeg-quantsmooth/images/text_orig.png\"\u003e \u003cimg src=\"https://ilyakurdyukov.github.io/jpeg-quantsmooth/images/lena_orig.png\"\u003e\u003cbr\u003e\nJPEG with quality increasing from 8% to 98%:\u003cbr\u003e\n\u003cimg src=\"https://ilyakurdyukov.github.io/jpeg-quantsmooth/images/text_jpg.png\"\u003e \u003cimg src=\"https://ilyakurdyukov.github.io/jpeg-quantsmooth/images/lena_jpg.png\"\u003e\u003cbr\u003e\nAfter processing:\u003cbr\u003e\n\u003cimg src=\"https://ilyakurdyukov.github.io/jpeg-quantsmooth/images/text_new.png\"\u003e \u003cimg src=\"https://ilyakurdyukov.github.io/jpeg-quantsmooth/images/lena_new.png\"\u003e\u003cbr\u003e\n\u003c/b\u003e\u003c/p\u003e\n\n## Building on Linux\n\nIf your system have *libjpeg* development package installed, just type `make`.\nTested with `libjpeg-turbo8-dev` package from Ubuntu-18.04.\n\n### Building for Linux distribution\n\nUse the `SIMD=select` switch, so that `jpegqs` is compiled for different CPU vector extensions.\n\n*amd64* application: `make SIMD=select MFLAGS=\"-m64\" clean app`  \n*i386* application: `make SIMD=select MFLAGS=\"-m32 -march=i386\" clean app`  \n\nPackage dependencies: libc, libjpeg, openmp\n\n### Building with libjpeg sources\n\n1. Download and extract *libjpeg* sources:\n    1. *libjpeg*, for example version 6b  \n    `wget https://www.ijg.org/files/jpegsrc.v6b.tar.gz`  \n    `tar -xzf jpegsrc.v6b.tar.gz`\n    2. *libjpeg-turbo*, for example version 2.0.4  \n    `wget -O libjpeg-turbo-2.0.4.tar.gz https://sourceforge.net/projects/libjpeg-turbo/files/2.0.4/libjpeg-turbo-2.0.4.tar.gz`  \n    `tar -xzf libjpeg-turbo-2.0.4.tar.gz`\n\n- For a *libjpeg* (not *turbo*) you can build `jpegqs` in a simpler way:  \n`make JPEGSRC=jpeg-6b`  \nThis uses static configuration from `jconfig.h`, which should work for common systems.  \nThe following items are not needed if you do so.  \n\n2. Configure and build *libjpeg*:\n    1. For *libjpeg* and *libjpeg-turbo-1.x.x*:  \n    `(cd jpeg-6b \u0026\u0026 ./configure \u0026\u0026 make all)`\n    2. For *libjpeg-turbo-2.x.x* `./configure` script is replaced with `cmake`:  \n    `(cd libjpeg-turbo-2.0.4 \u0026\u0026 mkdir -p .libs \u0026\u0026 (cd .libs \u0026\u0026 cmake -G\"Unix Makefiles\" .. \u0026\u0026 make all))`\n\n3. Tell `make` where to find *libjpeg* includes and `libjpeg.a`  \n`make JPEGLIB=\"-Ijpeg-6b jpeg-6b/libjpeg.a`  \nFor a newer versions `libjpeg.a` is located in a `.libs/` dir.\n\n### libjpeg build helper\n\nThe `jpegqs` makefile can download sources, extract and compile `libjpeg` for you. Replace `%VER%` with a version.\n\n- libjpeg: `make jpeg-%VER%/libjpeg.a`\nTested versions: 6b, 7, 8d, 9c\n- libjpeg-turbo:`make libjpeg-turbo-%VER%/libjpeg.a`\nTested versions: 1.0.0, 1.4.2, 1.5.3, 2.0.4\n\nIt will print you link to archive which you need to download, or you can allow the downloads by adding `WGET_CMD=wget` to the `make` command line.\n\n## Building on Windows\n\nGet [MSYS2](https://www.msys2.org/), install needed packages with pacman and build with __release.sh__.\nIf you are not familiar with building unix applications on windows, then you can download program from [releases](https://github.com/ilyakurdyukov/jpeg-quantsmooth/releases).\n\n## Use as a library\n\nCan be easily added to other software that uses `libjpeg` to read JPEG images.\n\n1. Find the source that uses `jpeg_start_decompress` and `jpeg_finish_decompress`.\n2. Add include, either `quantsmooth.h` (compile jpegqs as inline) or `libjpegqs.h` (link to the jpegqs library).\n3. Change `jpeg_` to `jpegqs_` for these two functions.\n4. Calling `jpegqs_start_decompress` takes an additional argument with options, see `example.c` for how to use it.\n\n- Build `libjpegqs.a` static library with `make SIMD=select lib`\n\n## Alternatives and comparison\n\nSimilar projects, and how I see them after some testing.\n\n[**jpeg2png**](https://github.com/victorvde/jpeg2png):  \n\u0026nbsp;✔️ good documentation and math model  \n\u0026nbsp;✔️ has tuning options  \n\u0026nbsp;✔️ better at deblocking low quality JPEG images  \n\u0026nbsp;❓ has an overblurring (`-w 0.0` switch makes the result a little sharper, but doesn't fix it)  \n\u0026nbsp;➖ 10 to 20 times slower  \n\u0026nbsp;➖ less permissive license (GPL-3.0)  \n\n**jpeg2png** can provide roughly same quality (better in not common cases), but significantly slower.\n\n[**knusperli**](https://github.com/google/knusperli):  \n\u0026nbsp;✔️ more permissive license (Apache-2.0)  \n\u0026nbsp;➖ you can hardly see any improvements on the image  \n\u0026nbsp;➖ no performance optimizations (but roughly same speed as for \u003cb\u003equantsmooth\u003c/b\u003e with optimizations)  \n\u0026nbsp;➖ no any command line options  \n\u0026nbsp;➖ uncommon build system  \n\n**knusperli** is good for nothing, in my opinion.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filyakurdyukov%2Fjpeg-quantsmooth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Filyakurdyukov%2Fjpeg-quantsmooth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filyakurdyukov%2Fjpeg-quantsmooth/lists"}