summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--init.php29
1 files changed, 21 insertions, 8 deletions
diff --git a/init.php b/init.php
index 996309b..1c037bd 100644
--- a/init.php
+++ b/init.php
@@ -2,6 +2,7 @@
class Api_Resize_Media extends Plugin {
const MAX_WIDTH = 1024;
+ const DEFAULT_QUALITY = 80;
/* @var PluginHost $host */
private $host;
@@ -35,7 +36,7 @@ class Api_Resize_Media extends Plugin {
}
private function make_thumbnail($input_filename, $output_filename, $dim_max_x = 600, $dim_max_y = 600,
- $content_type = "", $force_stamp = false) {
+ $content_type = "", $force_stamp = false, $quality = self::DEFAULT_QUALITY) {
if ($content_type == "image/webp") {
$o_im = @imagecreatefromwebp($input_filename);
@@ -100,7 +101,7 @@ class Api_Resize_Media extends Plugin {
else
@imagePng($t_im, $output_filename, 5);*/
- imagewebp($t_im, $output_filename, 80);
+ imagewebp($t_im, $output_filename, $quality);
imageDestroy($o_im);
imageDestroy($t_im);
@@ -122,8 +123,8 @@ class Api_Resize_Media extends Plugin {
return;
}
- if ($width > Api_Resize_Media::MAX_WIDTH)
- $width = Api_Resize_Media::MAX_WIDTH;
+ if ($width > self::MAX_WIDTH)
+ $width = self::MAX_WIDTH;
if ($this->cache->exists($local_filename)) {
@@ -370,6 +371,7 @@ class Api_Resize_Media extends Plugin {
if ($args != "prefFeeds") return;
$force_width = (int) $this->host->profile_get($this, "force_width", 0);
+ $quality = (int) $this->host->profile_get($this, "force_width", self::DEFAULT_QUALITY);
?>
<div dojoType='dijit.layout.AccordionPane'
@@ -388,11 +390,20 @@ class Api_Resize_Media extends Plugin {
}
</script>
- <fieldset>
- <label><?= $this->__( "Also resize in web UI (width, 0 - disables)") ?></label>
+ <fieldset class='prefs'>
+ <label><?= $this->__( "Also resize in web UI (width, 0 - disables):") ?></label>
<input dojoType='dijit.form.NumberSpinner'
title="<?= $this->__("This setting is local to current preference profile.") ?>"
- required='1' name='force_width' id='api_resize_force_width' value="<?= $force_width ?>"> <?= $this->__('pixels') ?>
+ required='1' name='force_width' value="<?= $force_width ?>">
+ &nbsp;
+ <?= $this->__('pixels') ?>
+ </fieldset>
+
+ <fieldset class='prefs'>
+ <label><?= $this->__( "Output WEBP quality:") ?></label>
+ <input dojoType='dijit.form.NumberSpinner' min='1' constraints='{min:1,max:100,places:0}'
+ title="<?= $this->__("This setting is local to current preference profile.") ?>"
+ required='1' name='quality' value="<?= $quality ?>">
</fieldset>
<hr/>
@@ -406,10 +417,12 @@ class Api_Resize_Media extends Plugin {
function save() {
$force_width = (int) $_POST["force_width"];
+ $quality = (int) $_POST["quality"];
$this->host->profile_set($this, "force_width", $force_width);
+ $this->host->profile_set($this, "quality", $quality);
- echo $this->T_sprintf("Data saved (%d)", $force_width);
+ echo $this->T_sprintf("Data saved (%d, %d)", $force_width, $quality);
}
function api_version() {