summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kremmel <xing@synapse.plus.com>2009-01-03 09:37:04 +0000
committerMax Kremmel <xing@synapse.plus.com>2009-01-03 09:37:04 +0000
commit1c8d37103647431999d4b4b5bc5519f2fb0065b5 (patch)
tree8a9d07e2a1d629a3a382c6a402c2f9beb26e49fc
parentddad4cc36a840a325ba1d10eed7eaf2b9613ad98 (diff)
downloadliberty-1c8d37103647431999d4b4b5bc5519f2fb0065b5.tar.gz
liberty-1c8d37103647431999d4b4b5bc5519f2fb0065b5.tar.bz2
liberty-1c8d37103647431999d4b4b5bc5519f2fb0065b5.zip
allow the user to specify the default compression setting for thumbnails
-rw-r--r--admin/admin_liberty_inc.php6
-rw-r--r--plugins/processor.gd.php10
-rw-r--r--plugins/processor.imagick.php8
-rw-r--r--plugins/processor.magickwand.php8
-rw-r--r--templates/admin_liberty.tpl10
5 files changed, 28 insertions, 14 deletions
diff --git a/admin/admin_liberty_inc.php b/admin/admin_liberty_inc.php
index 56d8659..6435d56 100644
--- a/admin/admin_liberty_inc.php
+++ b/admin/admin_liberty_inc.php
@@ -124,6 +124,11 @@ $formCaptchaTextareaFeatures = array(
);
$gBitSmarty->assign( 'formCaptchaTextareaFeatures', $formCaptchaTextareaFeatures );
+for( $i = 25; $i <= 100; $i += 5 ) {
+ $imageCompression[$i] = $i;
+}
+$gBitSmarty->assign( 'imageCompression', $imageCompression );
+
$formImageFeatures = array(
"liberty_thumbnail_pdf" => array(
'label' => 'Create PDF Thumbnails',
@@ -159,6 +164,7 @@ if( !empty( $_REQUEST['change_prefs'] )) {
foreach( $formCaptchaTextareaFeatures as $item => $data ) {
simple_set_value( $item, LIBERTY_PKG_NAME );
}
+ simple_set_int( 'liberty_thumbnail_quality', LIBERTY_PKG_NAME );
simple_set_value( 'liberty_thumbnail_format', LIBERTY_PKG_NAME );
simple_set_value( 'liberty_attachment_style', LIBERTY_PKG_NAME );
$gBitSystem->storeConfig( 'liberty_cache', $_REQUEST['liberty_cache'], LIBERTY_PKG_NAME );
diff --git a/plugins/processor.gd.php b/plugins/processor.gd.php
index 137529d..fb80c5c 100644
--- a/plugins/processor.gd.php
+++ b/plugins/processor.gd.php
@@ -1,6 +1,6 @@
<?php
/**
- * $Header: /cvsroot/bitweaver/_bit_liberty/plugins/processor.gd.php,v 1.13 2008/11/19 08:49:35 squareing Exp $
+ * $Header: /cvsroot/bitweaver/_bit_liberty/plugins/processor.gd.php,v 1.14 2009/01/03 09:37:04 squareing Exp $
*
* Image processor - extension: php-gd
* @package liberty
@@ -47,14 +47,14 @@ function liberty_gd_resize_image( &$pFileHash ) {
if( !empty( $img ) && $size_x && $size_y ) {
if( $size_x > $size_y && !empty( $pFileHash['max_width'] ) ) {
- $tscale = ((int)$size_x / $pFileHash['max_width']);
+ $tscale = ( (int)$size_x / $pFileHash['max_width'] );
} elseif( !empty( $pFileHash['max_height'] ) ) {
- $tscale = ((int)$size_y / $pFileHash['max_height']);
+ $tscale = ( (int)$size_y / $pFileHash['max_height'] );
} else {
$tscale = 1;
}
- $tw = ((int)($size_x / $tscale));
- $ty = ((int)($size_y / $tscale));
+ $tw = ( (int)( $size_x / $tscale ));
+ $ty = ( (int)( $size_y / $tscale ));
if( get_gd_version() > 1 ) {
$t = imagecreatetruecolor( $tw, $ty );
imagesavealpha( $t, TRUE );
diff --git a/plugins/processor.imagick.php b/plugins/processor.imagick.php
index 17a4e21..10ce11c 100644
--- a/plugins/processor.imagick.php
+++ b/plugins/processor.imagick.php
@@ -1,6 +1,6 @@
<?php
/**
- * $Header: /cvsroot/bitweaver/_bit_liberty/plugins/processor.imagick.php,v 1.11 2008/11/19 08:49:35 squareing Exp $
+ * $Header: /cvsroot/bitweaver/_bit_liberty/plugins/processor.imagick.php,v 1.12 2009/01/03 09:37:04 squareing Exp $
*
* Image processor - extension: php-imagick
* @package liberty
@@ -96,7 +96,7 @@ function liberty_imagick0_resize_image( &$pFileHash ) {
// $pFileHash['error'] = imagick_failedreason( $iImg ) . imagick_faileddescription( $iImg );
$destUrl = liberty_process_generic( $pFileHash, FALSE );
} else {
- imagick_set_image_quality( $iImg, 85 );
+ imagick_set_image_quality( $iImg, $gBitSystem->getConfig( 'liberty_thumbnail_quality', 85 ));
$iwidth = imagick_getwidth( $iImg );
$iheight = imagick_getheight( $iImg );
if( (($iwidth / $iheight) > 0) && !empty( $pFileHash['max_width'] ) && !empty( $pFileHash['max_height'] ) ) {
@@ -140,7 +140,7 @@ function liberty_imagick0_resize_image( &$pFileHash ) {
if( function_exists( 'imagick_set_attribute' ) ) {
// this exists in the PECL package, but not php-imagick
- $imagick_set_attribute($iImg,array("quality"=>1) );
+ $imagick_set_attribute( $iImg, array( "quality"=>1 ));
}
if( !imagick_writeimage( $iImg, $destFile ) ) {
@@ -200,7 +200,7 @@ function liberty_imagick2_resize_image( &$pFileHash ) {
if( !$im->valid()) {
$destUrl = liberty_process_generic( $pFileHash, FALSE );
} else {
- $im->setCompressionQuality( 85 );
+ $im->setCompressionQuality( $gBitSystem->getConfig( 'liberty_thumbnail_quality', 85 ));
$iwidth = $im->getImageWidth();
$iheight = $im->getImageHeight();
/*
diff --git a/plugins/processor.magickwand.php b/plugins/processor.magickwand.php
index 00cdce9..ca1a15f 100644
--- a/plugins/processor.magickwand.php
+++ b/plugins/processor.magickwand.php
@@ -1,6 +1,6 @@
<?php
/**
- * $Header: /cvsroot/bitweaver/_bit_liberty/plugins/processor.magickwand.php,v 1.21 2008/12/09 05:29:31 spiderr Exp $
+ * $Header: /cvsroot/bitweaver/_bit_liberty/plugins/processor.magickwand.php,v 1.22 2009/01/03 09:37:04 squareing Exp $
*
* Image processor - extension: php-magickwand
* @package liberty
@@ -38,7 +38,7 @@ function liberty_magickwand_resize_image( &$pFileHash ) {
// These two lines are a hack needed for version of Ghostscript less that 8.60
// MagickRemoveImageProfile( $magickWand, "ICC" );
// MagickSetImageProfile( $magickWand, 'ICC', file_get_contents( UTIL_PKG_PATH.'icc/USWebCoatedSWOP.icc' ) );
- MagickProfileImage($magickWand, 'ICC', file_get_contents( UTIL_PKG_PATH.'icc/srgb.icm' ) );
+ MagickProfileImage( $magickWand, 'ICC', file_get_contents( UTIL_PKG_PATH.'icc/srgb.icm' ));
MagickSetImageColorspace( $magickWand, MW_RGBColorspace );
$pFileHash['colorspace_conversion'] = TRUE;
}
@@ -46,7 +46,7 @@ function liberty_magickwand_resize_image( &$pFileHash ) {
MagickResetIterator( $magickWand );
MagickNextImage( $magickWand );
}
- MagickSetImageCompressionQuality( $magickWand, 85 );
+ MagickSetImageCompressionQuality( $magickWand, $gBitSystem->getConfig( 'liberty_thumbnail_quality', 85 ));
$iwidth = round( MagickGetImageWidth( $magickWand ) );
$iheight = round( MagickGetImageHeight( $magickWand ) );
@@ -60,7 +60,7 @@ function liberty_magickwand_resize_image( &$pFileHash ) {
// we have a portrait image, flip everything
$temp = $pFileHash['max_width'];
$pFileHash['max_height'] = $pFileHash['max_width'];
- $pFileHash['max_width'] = round( ($iwidth / $iheight) * $pFileHash['max_height'] );
+ $pFileHash['max_width'] = round(( $iwidth / $iheight ) * $pFileHash['max_height'] );
} elseif( !empty( $pFileHash['max_width'] ) ) {
$pFileHash['max_height'] = round(( $iheight / $iwidth ) * $pFileHash['max_width'] );
} elseif( !empty( $pFileHash['max_height'] ) ) {
diff --git a/templates/admin_liberty.tpl b/templates/admin_liberty.tpl
index 2afde5f..2094610 100644
--- a/templates/admin_liberty.tpl
+++ b/templates/admin_liberty.tpl
@@ -1,5 +1,5 @@
{strip}
-{form}
+{form}
{jstabs}
{jstab title="General Settings"}
{legend legend="Liberty Cache"}
@@ -115,6 +115,14 @@
{/foreach}
<div class="row">
+ {formlabel label="Image Compression" for="liberty_thumbnail_quality"}
+ {forminput}
+ {html_options values=$imageCompression options=$imageCompression id=liberty_thumbnail_quality name=liberty_thumbnail_quality selected=$gBitSystem->getConfig('liberty_thumbnail_quality')|default:85}
+ {formhelp note="Set the quality you want to have your thumbnails generated in. The higher the value, the better the quality but also the larger the filesize. We recommend a value between 75 and 85."}
+ {/forminput}
+ </div>
+
+ <div class="row">
{formlabel label="Thumbnail Format" for="thumbformat"}
{forminput}
{html_options values=$thumbFormats options=$thumbFormats id=thumbformat name=liberty_thumbnail_format selected=$gBitSystem->getConfig('liberty_thumbnail_format')}