static function install() { $defaults = array('jpg' => '1', 'png' => '2', 'gif' => '1'); foreach ($defaults as $type => $optlevel) { // set default path as the pre-compiled versions in the lib module::set_var("image_optimizer", "path_" . $type, MODPATH . "image_optimizer/lib/" . image_optimizer::tool_name($type)); // check config status (also sets configstatus_ variables and ensures that the permissions are set correctly) image_optimizer::tool_status($type); // set default optimization levels module::set_var("image_optimizer", "optlevel_thumb_" . $type, $optlevel); module::set_var("image_optimizer", "optlevel_resize_" . $type, $optlevel); } module::set_var("image_optimizer", "rotate_jpg", true); module::set_var("image_optimizer", "enable_thumb", true); module::set_var("image_optimizer", "enable_resize", true); module::set_var("image_optimizer", "update_mode_thumb", false); module::set_var("image_optimizer", "update_mode_resize", false); module::set_var("image_optimizer", "metastrip_thumb", true); module::set_var("image_optimizer", "convert_thumb_png", "jpg"); module::set_var("image_optimizer", "convert_resize_png", false); module::set_var("image_optimizer", "convert_thumb_gif", "jpg"); module::set_var("image_optimizer", "convert_resize_gif", false); module::set_var("image_optimizer", "metastrip_resize", false); module::set_var("image_optimizer", "progressive_thumb", false); module::set_var("image_optimizer", "progressive_resize", true); module::set_version("image_optimizer", 1); image_optimizer::add_image_optimizer_rule("thumb"); image_optimizer::add_image_optimizer_rule("resize"); }
static function tool_installed_path($type) { $type = strtolower($type); $path = exec('which ' . image_optimizer::tool_name($type)); $path = is_file($path) ? $path : "(not found)"; return $path; }
private function _get_admin_form() { $form = new Forge("admin/image_optimizer/save", "", "post", array("id" => "g-image-optimizer-admin-form")); $group_paths = $form->group("paths")->label(t("Toolkit paths"))->set_attr("id", "g-image-optimizer-admin-form-paths"); foreach (array('jpg', 'png', 'gif') as $type) { $path = strval(module::get_var("image_optimizer", "path_" . $type, null)); $group_paths->input("path_" . $type)->label(t("Path for") . " " . image_optimizer::tool_name($type) . " (" . t("no symlinks, default") . " " . MODPATH . "image_optimizer/lib/" . image_optimizer::tool_name($type) . ")")->value($path); } $group_rotate = $form->group("rotate")->label(t("Full-size image rotation"))->set_attr("id", "g-image-optimizer-admin-form-rotate"); $group_rotate->checkbox("rotate_jpg")->label(t("Override default toolkit and use") . " " . image_optimizer::tool_name('jpg') . " " . t("for rotation"))->checked(module::get_var("image_optimizer", "rotate_jpg", null)); foreach (array('thumb', 'resize') as $target) { ${'group_' . $target} = $form->group($target)->label(ucfirst($target) . " " . t("images optimization"))->set_attr("id", "g-image-optimizer-admin-form-" . $target); ${'group_' . $target}->checkbox("enable_" . $target)->label(t("Enable optimization"))->checked(module::get_var("image_optimizer", "enable_" . $target, null)); ${'group_' . $target}->checkbox("update_mode_" . $target)->label(t("Enable update mode - deactivates all other graphics rules to allow fast optimization on existing images; MUST deactivate this after initial rebuild!"))->checked(module::get_var("image_optimizer", "update_mode_" . $target, null)); ${'group_' . $target}->checkbox("rebuild_" . $target)->label(t("Mark all existing images for rebuild - afterward, go to Maintenace | Rebuild Images"))->checked(false); // always set as false ${'group_' . $target}->dropdown("convert_" . $target . "_png")->label(t("PNG conversion"))->options(array(0 => t("none"), "jpg" => "JPG " . t("(not lossless)")))->selected(module::get_var("image_optimizer", "convert_" . $target . "_png", null)); ${'group_' . $target}->dropdown("convert_" . $target . "_gif")->label(t("GIF conversion"))->options(array(0 => t("none"), "jpg" => "JPG " . t("(not lossless)"), "png" => "PNG " . t("(lossless)")))->selected(module::get_var("image_optimizer", "convert_" . $target . "_gif", null)); ${'group_' . $target}->dropdown("optlevel_" . $target . "_jpg")->label(t("JPG compression optimization (default: enabled)"))->options(array(0 => t("disabled"), 1 => t("enabled")))->selected(module::get_var("image_optimizer", "optlevel_" . $target . "_jpg", null)); ${'group_' . $target}->dropdown("optlevel_" . $target . "_png")->label(t("PNG compression optimization (default: level 2)"))->options(array(0 => t("disabled"), 1 => t("level 1: 1 trial"), 2 => t("level 2: 8 trials"), 3 => t("level 3: 16 trials"), 4 => t("level 4: 24 trials"), 5 => t("level 5: 48 trials"), 6 => t("level 6: 120 trials"), 7 => t("level 7: 240 trials")))->selected(module::get_var("image_optimizer", "optlevel_" . $target . "_png", null)); ${'group_' . $target}->dropdown("optlevel_" . $target . "_gif")->label(t("GIF compression optimization (default: enabled)"))->options(array(0 => t("disabled"), 1 => t("enabled")))->selected(module::get_var("image_optimizer", "optlevel_" . $target . "_gif", null)); ${'group_' . $target}->checkbox("metastrip_" . $target)->label(t("Remove all meta data"))->checked(module::get_var("image_optimizer", "metastrip_" . $target, null)); ${'group_' . $target}->checkbox("progressive_" . $target)->label(t("Make images progressive/interlaced"))->checked(module::get_var("image_optimizer", "progressive_" . $target, null)); } $form->submit("")->value(t("Save")); return $form; }