[Rt-commit] rt branch, 4.0/show-valid-image-types, updated. rt-4.0.0rc6-32-gd1c91dc
Thomas Sibley
trs at bestpractical.com
Mon Mar 14 11:50:26 EDT 2011
The branch, 4.0/show-valid-image-types has been updated
via d1c91dc9fc48947eb75a29d39c71ce1a6abc4e53 (commit)
from 4a330c749a6b170b3fd73b14bef869c8540bda47 (commit)
Summary of changes:
share/html/Admin/Tools/Theme.html | 43 +++++++++++++++++++++++-------------
1 files changed, 27 insertions(+), 16 deletions(-)
- Log -----------------------------------------------------------------
commit d1c91dc9fc48947eb75a29d39c71ce1a6abc4e53
Author: Thomas Sibley <trs at bestpractical.com>
Date: Mon Mar 14 11:48:23 2011 -0400
Update the wording and show supported image types without uploading
"Automatic color suggestions" is better than "color analyzation"
diff --git a/share/html/Admin/Tools/Theme.html b/share/html/Admin/Tools/Theme.html
index ae3bac1..99648a1 100644
--- a/share/html/Admin/Tools/Theme.html
+++ b/share/html/Admin/Tools/Theme.html
@@ -60,6 +60,13 @@
<form method="POST" enctype="multipart/form-data">
<label for="logo-upload"><&|/l&>Upload a new logo</&>:</label>
<input type="file" name="logo-upload" id="logo-upload" /><br />
+ <div class="gd-support">
+% if (%gd_can) {
+ <&|/l, join(", ", map { uc } sort { lc $a cmp lc $b } keys %gd_can) &>Your system supports automatic color suggestions for: [_1]</&>
+% } else {
+ <&|/l&>GD is disabled or not installed. You can upload an image, but you won't get automatic color suggestions.</&>
+% }
+ </div>
<input name="reset_logo" value="Reset to default RT Logo" type="submit" />
<input type="submit" value="Upload" />
</form>
@@ -247,26 +254,30 @@ use List::MoreUtils qw(uniq);
my $has_color_analyzer = eval { require Convert::Color; 1 };
my $colors;
+my %gd_can;
-if ( $imgdata
- and not RT->Config->Get('DisableGD')
- and $has_color_analyzer)
-{
+if (not RT->Config->Get('DisableGD') and $has_color_analyzer) {
require GD;
- if ( my $img = GD::Image->new($imgdata) ) {
- $colors = analyze_img($img);
+
+ # Always find out what GD can read...
+ for my $type (qw(Png Jpeg Gif)) {
+ $gd_can{$type}++ if GD::Image->can("newFrom${type}Data");
}
- else {
- my %can;
- for my $type (qw(Png Jpeg Gif)) {
- $can{$type}++ if GD::Image->can("newFrom${type}Data");
+
+ # ...but only analyze the image if we have data
+ if ($imgdata) {
+ if ( my $img = GD::Image->new($imgdata) ) {
+ $colors = analyze_img($img);
+ }
+ else {
+ push @results, loc(
+ "Automatically suggested theme colors aren't available for your image. This might be"
+ . " because you uploaded an image type that your installed version"
+ . " of GD doesn't support. Supported types are: [_1]."
+ . " You can recompile libgd and GD.pm to include support for other image types.",
+ join(", ", map { uc } sort { lc $a cmp lc $b } keys %gd_can)
+ );
}
- push @results, loc(
- "Unable to read image to analyze colors. This might be"
- . " because you uploaded an image type that your particular version"
- . " of GD doesn't support. Supported types are: [_1]",
- join(", ", map { uc } keys %can)
- );
}
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list