Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement --lossy LZW compression #72

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/lcdfgif/gif.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ typedef void (*Gif_ReadErrorHandler)(Gif_Stream* gfs,

typedef struct {
int flags;
int loss;
void *padding[7];
} Gif_CompressInfo;

Expand Down
1 change: 1 addition & 0 deletions src/giffunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,7 @@ void
Gif_InitCompressInfo(Gif_CompressInfo *gcinfo)
{
gcinfo->flags = 0;
gcinfo->loss = 0;
}


Expand Down
9 changes: 9 additions & 0 deletions src/gifsicle.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ static const char *output_option_types[] = {
#define SAME_APP_EXTENSIONS_OPT 373
#define IGNORE_ERRORS_OPT 374
#define THREADS_OPT 375
#define LOSSY_OPT 376

#define LOOP_TYPE (Clp_ValFirstUser)
#define DISPOSAL_TYPE (Clp_ValFirstUser + 1)
Expand Down Expand Up @@ -264,6 +265,7 @@ const Clp_Option options[] = {

{ "logical-screen", 'S', LOGICAL_SCREEN_OPT, DIMENSIONS_TYPE, Clp_Negate },
{ "loopcount", 'l', 'l', LOOP_TYPE, Clp_Optional | Clp_Negate },
{ "lossy", 0, LOSSY_OPT, Clp_ValInt, Clp_Optional },

{ "merge", 'm', 'm', 0, 0 },
{ "method", 0, COLORMAP_ALGORITHM_OPT, COLORMAP_ALG_TYPE, 0 },
Expand Down Expand Up @@ -1944,6 +1946,13 @@ main(int argc, char *argv[])
}
break;

case LOSSY_OPT:
if (clp->have_val)
gif_write_info.loss = clp->val.i;
else
gif_write_info.loss = 20;
break;

/* RANDOM OPTIONS */

case NO_WARNINGS_OPT:
Expand Down
Loading