Skip to content

Commit

Permalink
io-webp.c: simplify string to 0-100 int conversion for quality option
Browse files Browse the repository at this point in the history
  • Loading branch information
Alberto Ruiz committed Feb 23, 2023
1 parent 2e1c547 commit 48d9524
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions io-webp.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,10 @@ save_webp (GdkPixbuf *pixbuf,
{
if (strncmp (*kiter, "quality", 7) == 0)
{
float quality = (float) g_ascii_strtod (*viter, NULL);
if (quality < 0 || quality > 100)
{
g_set_error (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_BAD_OPTION,
"WebP quality must be a value between 0 and "
"100.");
return FALSE;
}
config.quality = quality;
guint64 quality;
if (! g_ascii_string_to_unsigned (*viter, 10, 0, 100, &quality, error))
return FALSE;
config.quality = (float) quality;
}
else if (strncmp (*kiter, "preset", 6) == 0)
{
Expand Down

0 comments on commit 48d9524

Please sign in to comment.