Way to display star ratings permanently?

Hert
Posts: 21018
Joined: 13 Sep 03 7:24

Re: Way to display star ratings permanently?

Post by Hert » 13 Oct 13 14:59

David's script provided a great base for all these variations for different needs.

Thank you all for sharing the scripts that you use.
Hert
This is a User-to-User forum which means that users post questions here for other users.
Feature requests, change suggestions, or bugs can be logged in the ticketing system

David Grundy
Posts: 319
Joined: 13 May 07 16:40
Location: Hong Kong

Re: Way to display star ratings permanently?

Post by David Grundy » 03 Feb 14 15:12

Update (thanks to Hert) ...

For PSu v2, there is no need for the vertical offset specified in this and some other scripts. Remove unwanted occurences of <ind y="2"> and </ind> from the older versions of the code to fix the vertical position of the info line elements.

David Grundy
Posts: 319
Joined: 13 May 07 16:40
Location: Hong Kong

Re: Way to display star ratings permanently?

Post by David Grundy » 03 Feb 14 15:39

Just for fun, my latest version (with this change incorporated). I find this way of representing the star ratings easier than the other ways I have tried.

Ratings shown: 0-5 (left - right), indicated by the yellow symbol.
Other notes about these files, shown in the thumbs display:
0 -
1 - has a recipe applied (green R)
2 -
3 -
4 - is a non-main version (red triangle)
5 - is a main version (green triangle)
Thumbinfo 20140203.JPG
Thumbinfo 20140203.JPG (28.9 KiB) Viewed 6125 times

Code: Select all

%code
// 2014-02-03 v7g Remove vertical indents (ind y=2) which are no longer needed in v2 (Tweak by Hert based on v7e) (forum.idimager.com/viewtopic.php?f=57&t=23131)
// Versions after 7f are for PSu v2
// 2014-01-05 v7f Add Recipe indicator (while experimenting with recipes)
// 2014-01-05 v7e Take out VUTs
// 2013-08-03 v7d Add the version count to the start of the line
// 2013-07-31 v7c Change colour of Version triangles to agree with the Main version VUT colour
// 2013-07-29 v7b Show VUTs (add Camera, HDR, BW, XNoFunction)
// 2013-07-27 v7 Show VUTs (implemented using the Custom Input Fields)
// 2013-07-27 v6d Replace stars with a part-filled square
// 2013-07-13 v5b, modified colours
// 2013-06-30 v5a, split version indicator from rating stars
// 2013-06 early versions based on code by Hert

// Note to self: Colours seem to be specified as ARGB Hex

var
  ACatItem: TCatalogItem;
  AVersionColor: String;
  AVersionShape: String;
  ARatingColor: String;
  ASetRatingColor: String;
  ANumVersions: Integer;
  i: Integer;
begin
  result := '';

  ARatingColor := '#FFCCCC00'; //#### Yellow colour for rating shapes
  ASetRatingColor := '" pathfillcolor="' + ARatingColor + '" pathstrokestyle="solid" pathstrokecolor="' + ARatingColor + '">';

  ARatingShape1 := 'M 0,0 '; //#### First part of rating shape
  ARatingShape2 := ' L 5,5 L 0,5 L 0,0 Z'; //#### Second part of rating shape

  AVersionShape := 'M 0,0 L 1,1 L 0,1 L 0,0 Z'; //#### Triangle shape for the version indicator

  ACatItem := TCatalogItem.Create(nil);
  if Catalog.FindImageCombined (ImageItem, ACatItem, False, vptNone) then
  begin

// Number of versions

    ANumVersions := ACatItem.VersionCount+1;
    if ANumVersions = 1 then
      result := result + '<font color="#FF0000FF">';
    else
      result := result + '<font color="#FFFFFFFF">';
    result := result + IntToStr(ANumVersions);
    result := result + '</font>';

// Show a shape coloured to indicated versions

    AVersionColor := '#FF0000CC'; //#### Blue colour for Solo (unVersioned) files
    if ACatItem.IsVersion then
      AVersionColor := '#FFCC0000'; //#### Red colour for non-Main Versions
    if (ACatItem._MainVersionGUID = ACatItem.GUID) and (ACatItem.VersionCount > 0) then
      AVersionColor := '#FF00CC00'; //#### Green colour for Main Versions

    result := result + '<font color="'+ AVersionColor +'">';
    result := result + '<img size="22" path="' + AVersionShape + '" pathfillcolor="' + AVersionColor + '">';
    result := result + ''; //####This line adds extra space after the version symbol
    result := result + '</font>';


// Show a shape to indicate the rating
    result := result + '<font color="'+ ARatingColor +'">';
    result := result + '<img size="22" path="';
    Case ACatItem.Rating of
    //#### Specify the shape to indicate the number of stars
      0: result := result + ' M 0,4 L 0,0 L -4,0 L 0,0 L 0,-4 L 0,0 L 4,0 L 0,0 L 0,4 Z ';
      1: result := result + ' M 0,4 L -3,3 L -4,0 L 0,0 L 0,-4 L 0,0 L 4,0 L 0,0 L 0,4 Z ';
      2: result := result + ' M 0,4 L -3,3 L -4,0 L -3,-3 L 0,-4 L 0,0 L 4,0 L 0,0 L 0,4 Z ';
      3: result := result + ' M 0,4 L -3,3 L -4,0 L -3,-3 L 0,-4 L 3,-3 L 4,0 L 0,0 L 0,4 Z ';
      4: result := result + ' M 0,4 L -3,3 L -4,0 L -3,-3 L 0,-4 L 3,-3 L 4,0 L 3,3 L 0,4 Z ';
      5: result := result + ' M 0,4 L -4,4 L -4,0 L -4,-4 L 0,-4 L 4,-4 L 4,0 L 4,4 L 0,4 Z';
    end;
    result := result + ASetRatingColor;
    result := result + ' '; //This line adds extra space
    result := result + '</font>';

//#### Show Recipe indicator
    if ImageItem._HasRecipe then
    result := result + '<FONT size="08" color="#FF00CC00">R' // Green
      else
    result := result + '<FONT size="08" color="#FF0000FF ">R'; // Blue
    result := result + '</FONT>';

  end;
  ACatItem.Free;
end;
%/code

Mike Buckley
Posts: 4561
Joined: 10 Jul 08 14:18

Re: Way to display star ratings permanently?

Post by Mike Buckley » 16 Sep 14 5:25

A huge "thank you" to everyone who contributed to this thread. I know absolutely nothing about coding but got really lucky and (probably accidentally) figured out what to delete from one of David Grundy's scripts to generate only white stars on a charcoal background.
Capture.JPG
Capture.JPG (19.98 KiB) Viewed 5831 times

Code: Select all

%code
var
  ACatItem: TCatalogItem;
  ARatingColor: String;
  ARatingStar: String;
  ARatingOnStar: String;
  ARatingOffStar: String;
  i: Integer;
begin
  result := '';
  ARatingStar := 'M 303,419.883 L 299.600,422.354 L 300.909,426.369 L 297.501,423.890 ' +
               'L 294.086,426.369 L 295.394,422.354 L 292,419.883 L 296.193,419.883 ' +
               'L 297.501,415.890 L 298.801,419.883 L 303,419.883 Z';
  ACatItem := TCatalogItem.Create(nil);
  if Catalog.FindImageCombined (ImageItem, ACatItem, False, vptNone) then
  begin
    ARatingColor := '#CCCCCCC';
    ARatingOnStar := '<img size="22" path="' + ARatingStar + '" pathfillcolor="' + ARatingColor + '">';
    ARatingOffStar := '<img size="22" path="' + ARatingStar + '" pathfillstyle="none" pathstrokestyle="solid" pathstrokecolor="' + ARatingColor + '">';

    for i := 1 to ACatItem.Rating do
      result := result + ARatingOnStar;
    for i := ACatItem.Rating + 1 to 5 do
      result := result + ARatingOffStar;

    result := result + '</ind></font>'
  end;
  ACatItem.Free;
end;
%/code

Hert
Posts: 21018
Joined: 13 Sep 03 7:24

Re: Way to display star ratings permanently?

Post by Hert » 16 Sep 14 8:03

Mike, Thank you for sharing your version of the script!

I've slightly changed your script. There was a closing tag for ind and font which wasn't needed. Also the color had one C too much. I made a change to illustrate how you can make colors have opacity. See the ARatingColorOff assignment.

Code: Select all

%code
var
  ACatItem: TCatalogItem;
  ARatingColor, ARatingOffColor: String;
  ARatingStar: String;
  ARatingOnStar: String;
  ARatingOffStar: String;
  i: Integer;
begin
  result := '';
  ARatingStar := 'M 303,419.883 L 299.600,422.354 L 300.909,426.369 L 297.501,423.890 ' +
               'L 294.086,426.369 L 295.394,422.354 L 292,419.883 L 296.193,419.883 ' +
               'L 297.501,415.890 L 298.801,419.883 L 303,419.883 Z';
  ACatItem := TCatalogItem.Create(nil);
  if Catalog.FindImageCombined (ImageItem, ACatItem, False, vptNone) then
  begin
    ARatingColor := '#CCCCCC';
    ARatingOffColor := '#80CCCCCC';
    ARatingOnStar := '<img size="22" path="' + ARatingStar + '" pathfillcolor="' + ARatingColor + '">';
    ARatingOffStar := '<img size="22" path="' + ARatingStar + '" pathfillstyle="none" pathstrokestyle="solid" pathstrokecolor="' + ARatingOffColor + '">';

    for i := 1 to ACatItem.Rating do
      result := result + ARatingOnStar;
    for i := ACatItem.Rating + 1 to 5 do
      result := result + ARatingOffStar;
  end;
  ACatItem.Free;
end;
%/code
This is a User-to-User forum which means that users post questions here for other users.
Feature requests, change suggestions, or bugs can be logged in the ticketing system

Mike Buckley
Posts: 4561
Joined: 10 Jul 08 14:18

Re: Way to display star ratings permanently?

Post by Mike Buckley » 16 Sep 14 11:27

Thanks for the tweak, Hert. By the way, I took the photo displayed in the thumbnail when I was with MikeP last year. If you think he's a great beta tester, he's an even better tour guide. :mrgreen:

Hert
Posts: 21018
Joined: 13 Sep 03 7:24

Re: Way to display star ratings permanently?

Post by Hert » 16 Sep 14 11:28

And it's a great shot. I love the intimacy of it...
This is a User-to-User forum which means that users post questions here for other users.
Feature requests, change suggestions, or bugs can be logged in the ticketing system

snowman1
Posts: 338
Joined: 01 Jan 07 3:13
Location: UK

Re: Way to display star ratings permanently?

Post by snowman1 » 16 Sep 14 14:05

+1 to that. Do you have your images on the web anywhere Mike? That's a lovely shot. (Apologies for being off-topic).
Snowman1
http://www.flickr.com/photos/snowman-1/
--------------------------------------

Mike Buckley
Posts: 4561
Joined: 10 Jul 08 14:18

Re: Way to display star ratings permanently?

Post by Mike Buckley » 16 Sep 14 17:53

OFF TOPIC

Thank you, guys!

Photos permanently displayed at my website are studio shots mostly of glass: http://mikebuckley.zenfolio.com/
Photos of our trip to South Africa to visit with MikeP and his wife: https://www.dropbox.com/sh/iajesx39tiyg ... -LNla?dl=0 EDIT: This link is no longer valid by design.
Last edited by Mike Buckley on 09 Jan 15 17:50, edited 1 time in total.

snowman1
Posts: 338
Joined: 01 Jan 07 3:13
Location: UK

Re: Way to display star ratings permanently?

Post by snowman1 » 16 Sep 14 22:17

[Off topic, can't seem to PM]
Great use of light in your shots. I expecially liked 08-Mike 2013-09-23--0190-L.jpg (elephant).
Snowman1
http://www.flickr.com/photos/snowman-1/
--------------------------------------

george
Posts: 1162
Joined: 24 Jun 07 15:57
Location: USA

Re: Way to display star ratings permanently?

Post by george » 16 Sep 14 23:16

Mike Buckley wrote:
Thank you, guys!

Photos permanently displayed at my website are studio shots mostly of glass: http://mikebuckley.zenfolio.com/
Photos of our trip to South Africa to visit with MikeP and his wife: https://www.dropbox.com/sh/iajesx39tiyg ... -LNla?dl=0
Hi Mike. Every once in a while I allow myself to think I'm an OK photographer, then I'm brought back to reality when I see what a truly accomplished photographer like you can do.
George

Mike Buckley
Posts: 4561
Joined: 10 Jul 08 14:18

Re: Way to display star ratings permanently?

Post by Mike Buckley » 16 Sep 14 23:55

Thanks, George! However, not only are you folks really embarrassing me, but you're also gonna get me banned for perpetuating this long string of off-topic posts. :mrgreen: Feel free to join me and lots of really wonderful, enjoyable photographers at http://www.cambridgeincolour.com/forums ... hid=845431 where we can discuss all of our photos.

Now, back to our regular programming -- Photo Supreme!

space
Posts: 69
Joined: 06 Feb 08 5:47
Location: Hong Kong
Contact:

Re: Way to display star ratings permanently?

Post by space » 09 Jan 15 16:35

Hi all,

Can anyone here please confirm that this ratings script works with PSu v3?

I've just upgraded from PSu v2 to v3 and now get a SCRIPT RUNTIME ERROR below all my thumbnail images. Haven't tried to run the script in PSu v3 yet. Maybe that's all that's required to correct this issue.

Can anyone here please confirm or advise otherwise.

TIA - Rogan

DirkS
moderator
Posts: 5234
Joined: 25 May 08 14:28
Location: Essex, UK

Re: Way to display star ratings permanently?

Post by DirkS » 09 Jan 15 21:56

space wrote:Can anyone here please confirm that this ratings script works with PSu v3?
This is what I see in v3 (the script is the third line.
2015-01-09_205134.png
2015-01-09_205134.png (429.88 KiB) Viewed 5356 times
If you have multiple lines and you get a script error, try all the lines individually to see which one is giving the problem. If you can't solve it, you can post the code here.
Make sure you have a backup copy of the script lines...

Gr.
Dirk.
Problems searching the forum? Try Google Site Search by adding 'site:forum.idimager.com' to a standard Google search.

Post Reply