EXPERTS: CustomMade / Different Thumbnail Sizes ? EXPERTS: CustomMade / Different Thumbnail Sizes ?
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

EXPERTS: CustomMade / Different Thumbnail Sizes ?

Started by frankyknife, July 23, 2004, 11:16:00 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

frankyknife

Hi Folks!
i have started with Coppermine Gallery some days ago, installation was easy and fast. it looks good...

After playing around for testing purposes i started creating my own theme.php. Unfortunately the docs, manuals, faqs etc. are not as detailed as needed, anyway i hope i will get some help/support here. :)
i have already searched for hours here in the support forum (and google) for what i am looking for, but failed! nevertheless if my trouble ticket has been already solved anywhere, so please dont blame me too much - a simple link would be very welcome!


First of all i am not talking about the standard ADMIN CONFIG things: i know that you can specify the ALBUM thumbnail size and the IMAGES thumbnail sizes there. but this only works fine if you would like to have the same or lower sized thumbs in album list view than in thumbnail list view!
but what is if you would like to do have it the other way? - i have read much about complains from others that the album thumbs look "blurry". this is obviously cause they have to be stretched bigger to fit the newer and larger defined album thumb size definition. => this is not practibale or usable, it looks painfully!


there are 3 ideas or possibilties i have thought about this topic:

1. the manual fake handjob version:
i can set up the standard thumbnail creation size to i.e. 200px height. after uploading the images i reconfigure the size back to i.e. 100px height WITHOUT admin resizing! so indeed i have the thumbs in 200px resolution on the server, but in thumbnail view they will be shown in 100px and the seperate album thumb has the correct 200px resolution as wished.
=> BIG DISADVANTAGE: i have everytime to set up the thumbnail creation size back to 200px before any additional uploading or image modifications is possible. and i see the result only after a second thumbnail reconfiguration again back to 100px. that is very hard and boring, also it is not very practical if you creating a new theme cause of the different table/cell sizes.

2. the feature request comfortable version:
how about selecting a completely different thumbnail image for the album list instead to choose from the generated thumbnail content images in there?
ok, i know there have to be done some seperated routines and forms to manage this but i think it would be very reasonable and comfortable. one problem may be that we have now two separated reslotions for thumbnail creations and have to store/edit them. i dont know how difficult to do is this? - i am not a coder/programer!

3. the modified coding version (at what i am working at the moment...):
i tried to solve this problem with modifications of the corresponding files, but due to lack of coding/php knowledge i messed up.

a) style.css: no chance cause there are no options to influence images/thumbs directly (only background images) - as far as i know!
.thumbnails {
       padding: 5px;
}


b) theme.php: maybe the easyiest and best idea but due to abstract variables i see no options there - maybe i am talking bullshit ;) here, too!? how can i influence/edit the THUMB (img) size there (see below in red)?
<!-- BEGIN thumb_cell -->
       <td valign="top" class="thumbnails" width="{CELL_WIDTH}" align="center">
               <table border="0" width="100%" cellpadding="0" cellspacing="0">
                       <tr>
                               <td align="center">


                                       <a href="{LINK_TGT}">{THUMB}<br /></a>


                                       {CAPTION}
                                       {ADMIN_MENU}
                               </td>
                       </tr>
               </table>
       </td>
<!-- END thumb_cell -->
<a href="{LINK_TGT}">{THUMB}<br /></a>

c) functions.inc.php: uhhhhh! i have found the hardcoding part of this thing. now i am seriously in trouble! ;D take a look what i have tried so far (see below in red):
// Prints thumbnails of pictures in an album
function display_thumbnails($album, $cat, $page, $thumbcols, $thumbrows, $display_tabs)
{
       global $CONFIG, $AUTHORIZED, $HTTP_GET_VARS;
       global $album_date_fmt, $lang_display_thumbnails, $lang_errors, $lang_byte_units;

       $thumb_per_page = $thumbcols * $thumbrows;
       $lower_limit = ($page-1) * $thumb_per_page;

       $pic_data = get_pic_data($album, $thumb_count, $album_name, $lower_limit, $thumb_per_page);

       $total_pages = ceil($thumb_count / $thumb_per_page);

       $i = 0;
       if (count($pic_data) > 0) {
               foreach ($pic_data as $key => $row) {
                       $i++;

                       $pic_title =$lang_display_thumbnails['filename'].$row['filename']."\n".
                               $lang_display_thumbnails['filesize'].($row['filesize'] >> 10).$lang_byte_units[1]."\n".
                               $lang_display_thumbnails['dimensions'].$row['pwidth']."x".$row['pheight']."\n".
                               $lang_display_thumbnails['date_added'].localised_date($row['ctime'], $album_date_fmt);

                       $pic_url =  get_pic_url($row, 'thumb');
                       if (!is_image($row['filename'])) {
                               $image_info = getimagesize($pic_url);
                               $row['pwidth'] = $image_info[0];
                               $row['pheight'] = $image_info[1];
                       }

                       $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width']);
                       
                 
                       $thumb_size = $image_size * 0.5;
                       

                       $thumb_list[$i]['pos'] = $key < 0 ? $key : $i - 1 + $lower_limit;


                       $thumb_list[$i]['image'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$thumb_size['geom']} border=\"0\" alt=\"{$row['filename']}\" title=\"$pic_title\">";


                       $thumb_list[$i]['caption'] = $row['caption_text'];
                       $thumb_list[$i]['admin_menu'] = '';
                       $thumb_list[$i]['aid'] = $row['aid'];
               }
               theme_display_thumbnails($thumb_list, $thumb_count, $album_name, $album, $cat, $page, $total_pages, is_numeric($album), $display_tabs);
       } else {
               theme_no_img_to_display($album_name);
       }
}
$thumb_size = $image_size * 0.5; and $thumb_list[$i]['image'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$thumb_size['geom']} border=\"0\" alt=\"{$row['filename']}\" title=\"$pic_title\">";
the factor "* 0.5" should half the size the thumbnails, i.e. reducing the standard $image_size = 200px to 100px = $thumb_size. i am not sure what i am doing there, i have only some (amiga/pascal) basic knowledge from school times - sorry! maybe there are missing the correct variables...?!???


i hope someone can give me an advice. it would be very appreciated!


Many thanks,
Franky


Joachim Müller

Although I appreciate your long post, trying to explain with much detail, I confess I can't make heads or tails out of your question (maybe because my first language isn't english). Could you please describe in less words what your actual question is? Thanks.

GauGau

frankyknife

#2
Hi GauGau!
thanks for your fast reply, you are a doing a fantastic job here...

ok, lets try to explain you the main point about all here: i would like to have the album thumbnail (on index.php) to appear in different/larger size (true pixel size resolution) than the thumbnails inside the album (on thumbnails.php).
question: where and how can i edit/specify this?

i dont know how i can explain this in a better way and additionally to emphazise that i dont mean/talk about the admin config part.
as i see that you are from germany i will try it in german language - if i may 8) cause i am also from germany/switzerland so it may be much easier this way...:

[GERMAN ONLY]:
ok, die sache ist die, dass ich die vorderen thumbnails, also in der kategorie/album ansicht in einer anderen, nämlich höheren auflösung haben möchte. wenn ich ein album erstelle, kann ich das passende thumbnail hierfür ja nur aus den schon generierten thumbnails von den hochgeladenen bildern aussuchen. diese sind angenommen auf max. 100px eingestellt (in admin config -> Files and thumbnails settings: Max dimension of a thumbnail **). wenn ich jetzt aber die grösse der album thumbnails in z.b. auf 200px einstelle (in admin config -> Album list view: Size of thumbnails in pixels) werden die bestehenden thumbnails im img width und size tag während der ausgabe dann logischerweise auf diese 200px hoch-gestretcht. dies sieht natürlich schlecht und unprofessionell aus und macht alles zunichte!
andersherum funktioniert das ja einwandfrei, also wenn ich z.b. die albem thumbnail ansicht auf 50px einstellen würde, würden die bestehenden thumbnails (100px) herunter-gestretcht. das führt dann zu keinen problemen, bei verkleinerungen von bildern leidet die qualität bekannterweise nicht!

wie man nun sehen kann, ist die getrennte angabe von thumbnail grössen im admin config menu eine heikle sache, da man leider nur aus demselben fundus von thumbnails wählen kann, die alle eine einheitsgrösse haben (in diesem falle 100px).
wünschenswert bzw. eigentlich korrekterweise sollte man hier (bei modifyalb.php) das album thumbail neu bestimmen/hochladen können und nicht einfach nur aus der liste der bestehenden bildern wählen können! ...es könnte ja z.b. auch sein, das man ein extra cover bild für the album ansicht erstellt und auswählen möchte. ich möchte wie gesagt ein grösseres thumbnail in richtiger qualität dort stehen haben.


ich habe mir nun ein paar dinge hierzu überlegt wie ich das bewerkstelligen kann, bin aber an einen punkt gelangt wo ich alleine nicht mehr weiterkomme.
die 3 verschiedenen möglichkeiten findest du oben unter punkt 1 - 3 !
bei möglichkeit nr. 3 gibt es meiner ansicht nach 3 mögliche ansätze, dies selbst angeben zu können:
a) style.css: wahrscheinllich nicht möglich, dort getrennt über eine 'span class' einfluss auf die grössendarstellung eines bildes zu nehmen. ich habe jedenfalls bei den offiziellen css angaben nichts hierzu finden können.
b) theme.php: im theme selbst, wo ja die gesamte html ausgabe eigentlilch definiert wird. (s. code oben).
leider komme ich auch dort nicht weiter, weil es eher abstrakte zuweisungen zu php definierte variablen sind - ohne jegliche ausgabe formatierungen wie z.b. img size.
c) functions.inc.php: hier konnte ich die direkte ausgabe/formatierung lokalisieren. (s. code oben).
wenn ich nun in der zeile $thumb_list[$i]['image'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$row['filename']}\" title=\"$pic_title\">";  den part {$image_size['geom']} z.b. durch die angabe von width=\"100\" height=\"100\" ersetze, erhalte ich zwar den gewünschten effekt, also thumbnail darstellung in 100px. es ist aber so gesehen eine sehr fixe angabe. ich würde dies gerne abhängig von der admin config einstellung machen, wie hier versucht mit der simplen variablen-definition und rechenoperation um den faktor 0.5 : $thumb_size = $image_size * 0.5;
-> dies funktioniert leider nicht, es gibt eine fehlermeldung in dieser zeile.


[NEW]
d) eine weitere möglichkeit ist mir soeben eingefallen, und zwar könnte ich doch - wenn ja bekannterweise das herunter-sizen bei der darstellung/html-ausgabe keine negativen auswirkungen hat - bei der angabe des album thumbails nicht die thumb_ versionen eines images nehmen, sondern die intermediate_ version, oder?
d.h. ich müsste bei der angabe der album ansicht des {ALB_LINK_PIC} nicht die thumb version zuweisen, sondern die intermediate version. wo und wie kann ich dies tun (irgendwo in einem .php file, oder) ?
<!-- BEGIN album_cell -->
       <td width="{COL_WIDTH}%" height="100%" valign="top">
       <table border="0" width="100%" height="100%" cellspacing="0" cellpadding="0">
       <tr>
               <td colspan="3" height="1" valign="top" class="tableh2">
                       <a href="{ALB_LINK_TGT}" class="alblink"><b>{ALBUM_TITLE}</b></a>
               </td>
       </tr>
       <tr>
               <td colspan="3">
                       <img src="images/spacer.gif" width="1" height="1"><br />
               </td>
       </tr>
       <tr height="100%">
               <td align="center" height="100%" valign="middle" class="thumbnails">
                       <img src="images/spacer.gif" width="{THUMB_CELL_WIDTH}" height="1" class="image" style="margin-top: 0px; margin-bottom: 0px; border: none;"><br />
                       <a href="{ALB_LINK_TGT}" class="albums">{ALB_LINK_PIC}<br /></a>
               </td>
               <td height="100%">
                       <img src="images/spacer.gif" width="1" height="1">
               </td>
               <td width="100%" height="100%" valign="top" class="tableb_compact">
                       {ADMIN_MENU}
                       <p>{ALB_DESC}</p>
                       <p class="album_stat">{ALB_INFOS}</p>
               </td>
       </tr>
       </table>
       </td>
<!-- END album_cell -->



merci für deine mühe und hilfe (wenn es klappt, kann ich ja per paypal donation euch was zukommen lasssen... damit hier nicht alles zu mühsam für euch wird),
franky

frankyknife

#3
Hi again!
i have now chosen the option d) for me!
i simply assigned the intermediate pictures to the thumbnail list view instead the thumb pic versions:

here is the part of the index.php i have changed:
// Inserts a thumbnail if the album contains 1 or more images

       $visibility = $alb_thumb['visibility'];
       if ($visibility == '0' || $visibility == (FIRST_USER_CAT + USER_ID) || in_array($visibility, $USER_DATA['groups']) || $USER_DATA['can_see_all_albums'] || $CONFIG['allow_private_albums']==0) {
           if ($count > 0) {
               if ($alb_thumb['filename']) {
                   $picture = &$alb_thumb;
               } else {
                   $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight ".
                          "FROM {$CONFIG['TABLE_PICTURES']} ".
                          "WHERE pid='{$alb_stat['last_pid']}'";
                   $result = db_query($sql);
                   $picture = mysql_fetch_array($result);
                   mysql_free_result($result);
               }
               $pic_url =  get_pic_url($picture, 'normal');
               if (!is_image($picture['filename'])) {
                       $image_info = getimagesize($pic_url);
                       $picture['pwidth'] = $image_info[0];
                       $picture['pheight'] = $image_info[1];
               }
               $image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['alb_list_thumb_size']);
               $alb_list[$alb_idx]['thumb_pic'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$picture['filename']}\">";
           } else { // Inserts an empty thumbnail if the album contains 0 images
               $image_size = compute_img_size(100, 75, $CONFIG['alb_list_thumb_size']);

               $alb_list[$alb_idx]['thumb_pic'] = "<img src=\"images/nopic.jpg\" {$image_size['geom']} alt=\"\" border=\"0\" class=\"image\" />";
           }
       } elseif ($CONFIG['show_private']) {
           $image_size = compute_img_size(100, 75, $CONFIG['alb_list_thumb_size']);
           $alb_list[$alb_idx]['thumb_pic'] = "<img src=\"images/private.jpg\" {$image_size['geom']} alt=\"\" border=\"0\" class=\"image\" />";

       }


the responsible line for the size/version of the thumbnail for album list view is: $pic_url =  get_pic_url($picture, 'normal');
i have changed it from 'thumb'  to 'normal', so everytime the index.php is choosing the intermediate pic version now instead the smaller thumb pic for display.

this is much better to have it his way if you would like to choose larger thumbnails for the albums than the thumbnails! now you are a bit more independent if editing the album/thumb pic sizes.  :)

regards, franky


PS: ANY COMMENTS?

omniscientdeveloper

I don't understand why you had to change anything, since you can change the thumb sizes in config. Yes, there are two seperate values, but you can have them both the same. If you want thumbs to be 400px wide, it shouldn't matter.


-omni

Casper

What he was saying was that if the thumbs are created at 100px, but displayed at 200+, they will look terrible, which they do.

He didn't want the thumbs to be created at 200+, as it was only the ones on the cat page he wanted to display that big.
It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here

frankyknife

Quote from: Casper on July 27, 2004, 11:02:40 PM
What he was saying was that if the thumbs are created at 100px, but displayed at 200+, they will look terrible, which they do.

He didn't want the thumbs to be created at 200+, as it was only the ones on the cat page he wanted to display that big.

EXACTLY! - thx, Casper!

(i show the cat/album thumbs now as intermediate pictures in size width/height=300 (actual they are sized in 500px by coppermine for intermediate view), the thumbs in thumbnails view in width/height=80. it would be unlogical, crazy and resource waisting to display all thumbs there in 500px size, too!!! furthermore the intermediate thing would make no sense anymore, if intermediate and thumbs would be the same size/resolution! ::) )