{"id":15049386,"url":"https://github.com/amarok24/easyjpeg","last_synced_at":"2026-02-14T16:31:28.194Z","repository":{"id":80033171,"uuid":"540509757","full_name":"Amarok24/easyjpeg","owner":"Amarok24","description":"ANSI C/C++ header wrapper for jpeglib","archived":false,"fork":false,"pushed_at":"2022-09-23T15:46:25.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-14T01:16:23.543Z","etag":null,"topics":["c89","c90","cpp","jpeg","jpeglib","jpg"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Amarok24.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":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-23T15:42:08.000Z","updated_at":"2022-09-26T15:06:51.000Z","dependencies_parsed_at":"2023-09-19T04:15:56.170Z","dependency_job_id":null,"html_url":"https://github.com/Amarok24/easyjpeg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Amarok24/easyjpeg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amarok24%2Feasyjpeg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amarok24%2Feasyjpeg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amarok24%2Feasyjpeg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amarok24%2Feasyjpeg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Amarok24","download_url":"https://codeload.github.com/Amarok24/easyjpeg/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amarok24%2Feasyjpeg/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261823737,"owners_count":23215141,"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","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":["c89","c90","cpp","jpeg","jpeglib","jpg"],"created_at":"2024-09-24T21:20:03.488Z","updated_at":"2025-09-19T07:13:59.947Z","avatar_url":"https://github.com/Amarok24.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"EasyJpeg\n========\n\nThis C/C++ header file is a wrapper around IJG's [jpeglib](http://www.ijg.org), which has a terrible, nightmareish API,\neven involving the horrors of setjmp.\n\nThis was written in ANSI C (C89), and provides a nice and easy way for loading and saving JPEG files, with one struct\ndefinition and six functions only.\n\nIntended audience are embedded software or game developers in need of JPEG support, but where a several megabytes\nthird party library (like libGD or ImageMagick) is not feasable.\n\nHow to Use\n----------\n\nIn each of your source files, where you want to access the library, include the header:\n\n```c\n#include \u003ceasyjpeg.h\u003e\n```\n\nIn *exactly one* source file, where you want the code to be placed, specify a define too:\n\n```c\n#define EASYJPEG_IMPLEMENTATION\n#include \u003ceasyjpeg.h\u003e\n```\n\nAnd then link your program with\n\n```sh\n-ljpeg\n```\n\nFor examples on the API usage, see main.c which tests the library's functions. Detailed description below.\n\nLibrary Functions\n-----------------\n\nThe library stores an image in memory in the following, quite self-explanatory structure:\n\n```c\ntypedef struct {\n    int w;                  /* width */\n    int h;                  /* height */\n    unsigned int *d;        /* data, each pixel stored as 4 bytes */\n} image_t;\n```\n\nEasyJpeg gives you the following API to manipulate these structs:\n\n### Loading images\n\n```c\nimage_t *image_read_file(FILE *f);\nimage_t *image_read_mem(char *buf, int size);\n```\n\nConvert a JPEG compressed picture into a newly allocated image structure. Returns NULL on error, and exact error message\nis in `easyjpeg_errorstr`.  Grayscale images will be converted to sRGB automatically on load, other obscure pixel formats\n(CMYK, YCCK etc.) untouched.\n\nCan be turned off with the define `EASYJPEG_NOLOAD`.\n\n### Saving images\n\n```c\nint image_write_file(image_t *in, int quality, FILE *f);\nint image_write_mem(image_t *in, int quality, char **buf);\n```\n\nCompress an in memory image into a JPEG file with the given quality (1-100, 0=default). Returns zero on error. The output\nbuffer will be allocated as needed, and buffer size is returned. The file variant returns one on success. These functions\nintentinally DO NOT save any meta information (like comments, EXIF, photo shoot time or GPS longitude, latidute etc.) to\nprotect privacy. For simplicity, these only support sRGB pixel format (most widely used on the web). If you have loaded\na JPEG with different format (like CMYK), then you have to convert every pixel in image_t-\u003ed buffer before you can save\nit color-correctly.\n\nCan be turned off with the define `EASYJPEG_NOSAVE`.\n\n### Resizing images\n\n```c\nimage_t *image_resize(image_t *in, int w, int h, int crop);\n```\n\nIf required, you can use this function to quickly resize an in memory image. It's not optimal, uses the simpliest method,\nthe closest neightbour algorithm without resampling. But could be handy to generate thumbnails as it has absolutely no\ndependencies, and it's pixel format agnostic. The last crop parameter can be either EASYJPEG_RESIZE, when the resulting\nimage will be no bigger than `w` x `h`, keeping the original picture's aspect ratio. Or it can be EASYJPEG_CROP, then the\nresulting image will be exactly `w` x `h` pixels in dimension, and the picture will be cropped from the middle of the\nscaled image (portait images will be first scaled to match width, landscapes to match height before being cropped). If\nyou define `EASYJPEG_DOWNSCALE_ONLY` before including EasyJpeg header, then only integer arithmetic will be used (jpeglib\nitself can be compiled without any floating-number support, which could be important on embedded systems).\n\n````\nEASYJPEG_RESIZE\n+-+\n| |   @@@@     #          +-------+   @@@@    ####\n| | + @@@@ -\u003e  #          +-------+ + @@@@ -\u003e\n| |   @@@@     #                      @@@@\n+-+\n\nEASYJPEG_CROP\n+-+           ....\n| |   @@@@    ####        +-------+   @@@@    .....####.....\n| | + @@@@ -\u003e ####        +-------+ + @@@@ -\u003e .....####.....\n| |   @@@@    ####                    @@@@    .....####.....\n+-+           ....\n\n+- original image, @ desired dimension, # resulting image, . cropped parts\n````\n\nCan be turned off with the define `EASYJPEG_NORESIZE`.\n\n### Destroying images\n\n```c\nvoid image_free(image_t *img);\n```\n\nAnd finally, a function to free an allocated image structure.\n\nLicense\n-------\n\nMIT licensed. Use as you please.\n\nAuthor\n------\n\nbzt (bztsrc@gitlab)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famarok24%2Feasyjpeg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famarok24%2Feasyjpeg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famarok24%2Feasyjpeg/lists"}