Commit 136ef67b authored by skal's avatar skal Committed by Jehan

Bug 775026 - webp-save: expose more saving options in the UI

webp-save: Add UI elements for 'minimize size' toggle, and a dependent
'max key-frame distance' setting.
* If 'minimize size' is active, max-kf is disabled (which is equivalent to
  setting it to infinity). Key-frame cost file size, that's why.
* If 'minimize size' is disabled, you get to choose how far key-frames
  (=cue points) will be inserted at max.
parent 2e635336
......@@ -33,7 +33,10 @@
static void save_dialog_toggle_scale (GtkWidget *widget,
gpointer data);
gpointer data);
static void save_dialog_toggle_minsize (GtkWidget *widget,
gpointer data);
static void
......@@ -44,6 +47,14 @@ save_dialog_toggle_scale (GtkWidget *widget,
! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)));
}
static void
save_dialog_toggle_minsize (GtkWidget *widget,
gpointer data)
{
gtk_widget_set_sensitive (GTK_WIDGET (data),
! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)));
}
gboolean
save_dialog (WebPSaveParams *params,
gint32 image_ID,
......@@ -57,6 +68,7 @@ save_dialog (WebPSaveParams *params,
GtkWidget *vbox2;
GtkWidget *label;
GtkWidget *toggle;
GtkWidget *toggle_minsize;
GtkWidget *combo;
GtkObject *quality_scale;
GtkObject *alpha_quality_scale;
......@@ -170,6 +182,10 @@ save_dialog (WebPSaveParams *params,
GtkAdjustment *adj;
GtkWidget *delay;
GtkWidget *hbox;
GtkWidget *label_kf;
GtkAdjustment *adj_kf;
GtkWidget *kf_distance;
GtkWidget *hbox_kf;
vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
......@@ -221,6 +237,48 @@ save_dialog (WebPSaveParams *params,
G_CALLBACK (gimp_toggle_button_update),
&params->loop);
/* create a hbox for 'max key-frame distance */
hbox_kf = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
gtk_box_pack_start (GTK_BOX (animation_box), hbox_kf, FALSE, FALSE, 0);
gtk_widget_set_sensitive (hbox_kf, TRUE);
gtk_widget_show (hbox_kf);
/* label for 'max key-frame distance' adjustment */
label_kf = gtk_label_new (_("Max distance between key-frames:"));
gtk_label_set_xalign (GTK_LABEL (label_kf), 0.2);
gtk_box_pack_start (GTK_BOX (hbox_kf), label_kf, FALSE, FALSE, 0);
gtk_widget_show (label_kf);
/* key-frame distance entry */
adj_kf = (GtkAdjustment *) gtk_adjustment_new (params->kf_distance,
1, 10000, 1, 10, 0);
kf_distance = gtk_spin_button_new (adj_kf, 1, 0);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (kf_distance), TRUE);
gtk_box_pack_start (GTK_BOX (hbox_kf), kf_distance, FALSE, FALSE, 0);
gtk_widget_show (kf_distance);
g_signal_connect (adj_kf, "value-changed",
G_CALLBACK (gimp_int_adjustment_update),
&params->kf_distance);
/* minimize-size checkbox */
toggle_minsize = gtk_check_button_new_with_label (_("Minimize output size (slower)"));
gtk_box_pack_start (GTK_BOX (animation_box), toggle_minsize,
FALSE, FALSE, 0);
gtk_widget_show (toggle_minsize);
g_signal_connect (toggle_minsize, "toggled",
G_CALLBACK (gimp_toggle_button_update),
&params->minimize_size);
/* Enable and disable the kf-distance box when the 'minimize size' option is selected */
g_signal_connect (toggle_minsize, "toggled",
G_CALLBACK (save_dialog_toggle_minsize),
hbox_kf);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle_minsize), params->minimize_size);
/* create a hbox for delay */
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
gtk_box_pack_start (GTK_BOX (animation_box), hbox, FALSE, FALSE, 0);
......
......@@ -529,7 +529,13 @@ save_animation (const gchar *filename,
enc_options.anim_params.loop_count = 1;
enc_options.allow_mixed = params->lossless ? 0 : 1;
enc_options.minimize_size = 1;
enc_options.minimize_size = params->minimize_size ? 1 : 0;
if (! params->minimize_size)
{
enc_options.kmax = params->kf_distance;
/* explicitly force minimum key-frame distance too, for good measure */
enc_options.kmin = params->kf_distance - 1;
}
for (loop = 0; loop < nLayers; loop++)
{
......
......@@ -29,6 +29,8 @@ typedef struct
gboolean lossless;
gboolean animation;
gboolean loop;
gboolean minimize_size;
gint kf_distance;
gfloat quality;
gfloat alpha_quality;
gboolean exif;
......
......@@ -83,6 +83,8 @@ query (void)
{ GIMP_PDB_FLOAT, "alpha-quality", "Quality of the image's alpha channel (0 <= alpha-quality <= 100)" },
{ GIMP_PDB_INT32, "animation", "Use layers for animation (0/1)" },
{ GIMP_PDB_INT32, "anim-loop", "Loop animation infinitely (0/1)" },
{ GIMP_PDB_INT32, "minimize-size", "Minimize animation size (0/1)" },
{ GIMP_PDB_INT32, "kf-distance", "Maximum distance between key-frames (>=0)" },
{ GIMP_PDB_INT32, "exif", "Toggle saving exif data (0/1)" },
{ GIMP_PDB_INT32, "iptc", "Toggle saving iptc data (0/1)" },
{ GIMP_PDB_INT32, "xmp", "Toggle saving xmp data (0/1)" },
......@@ -193,6 +195,8 @@ run (const gchar *name,
params.lossless = FALSE;
params.animation = FALSE;
params.loop = TRUE;
params.minimize_size = TRUE;
params.kf_distance = 50;
params.quality = 90.0f;
params.alpha_quality = 100.0f;
params.exif = TRUE;
......@@ -220,7 +224,7 @@ run (const gchar *name,
break;
case GIMP_RUN_NONINTERACTIVE:
if (nparams != 16)
if (nparams != 18)
{
status = GIMP_PDB_CALLING_ERROR;
}
......@@ -237,11 +241,13 @@ run (const gchar *name,
params.alpha_quality = param[8].data.d_float;
params.animation = param[9].data.d_int32;
params.loop = param[10].data.d_int32;
params.exif = param[11].data.d_int32;
params.iptc = param[12].data.d_int32;
params.xmp = param[13].data.d_int32;
params.delay = param[14].data.d_int32;
params.force_delay = param[15].data.d_int32;
params.minimize_size = param[11].data.d_int32;
params.kf_distance = param[12].data.d_int32;
params.exif = param[13].data.d_int32;
params.iptc = param[14].data.d_int32;
params.xmp = param[15].data.d_int32;
params.delay = param[16].data.d_int32;
params.force_delay = param[17].data.d_int32;
}
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment