Album thumbnails appearing pixelated Album thumbnails appearing pixelated
 

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

Album thumbnails appearing pixelated

Started by alcorjr, February 04, 2016, 01:33:46 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

alcorjr

Hello guys, first of all I want to congratulate the developers for this excellent tool, (Cpg).

I do have a question, which I have observed in my latest install; the album thumbnails in the album gallery appear pixelated. I have tried the resize admin tool and it doesn't fix it. I think it might be , because I have set the albums (inside) thumbs at 220 px the largest, while the album thumbnail proper I have at 309 px.

Could this be the reason? It's like if the system just uses the smaller thumbnail to display in the album gallery page. Of course, as it gets enlarged, it gets pixelated.

Is there any way around this?

Thanks

Αndré

Coppermine doesn't create separate "album thumbnails", but uses the regular thumbnails which are displayed at thumbnails.php. To fix your issue while keeping your settings, we need to modify the code to use the intermediate-sized pictures (if available) or the full-sized pictures as image file for the album thumbnails.

alcorjr

Yes Andre, that's what I thought. Could you please tell me whay line of code I should modify? Thanks

Αndré

Open index.php, find
$pic_url = get_pic_url($picture, 'thumb');
and replace with
$pic_url = get_pic_url($picture, 'normal');
in functions list_albums and list_cat_albums

Note: there are two other occurrences of that line in index.php, so make sure
mysql_free_result($result);
is not above the other line. Instead, it has to be a right curly bracket (once in combination with a blank line).

Αndré

Note to myself: maybe a good idea to add a check if the album thumbnail if set larger than the picture thumbnail and/or intermediate-sized setting and then use the intermediate-sized or full-sized picture as album thumbnail instead.

alcorjr

Hello Andre,
Thanks for your help. I need some clarification, though. I have found four instances of the line of code you mention. Do I have to replace it in all of them?

1)
if ($cat['details']['thumb'] > 0) {
            $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight FROM {$CONFIG['TABLE_PICTURES']} AS p WHERE pid = {$cat['details']['thumb']} $FORBIDDEN_SET";
            $result = cpg_db_query($sql);
            if (mysql_num_rows($result)) {
                $picture = mysql_fetch_assoc($result);
                mysql_free_result($result);
                $pic_url = get_pic_url($picture, 'thumb');

2)
if (mysql_num_rows($result)) {
                $picture = mysql_fetch_assoc($result);
                mysql_free_result($result);
                $pic_url = get_pic_url($picture, 'thumb');

3)

        $keyword = ($alb_thumb['keyword'] ? "OR (keywords like '%".addslashes($alb_thumb['keyword'])."%' $forbidden_set_string )" : '');
        if (!in_array($aid, $FORBIDDEN_SET_DATA) || $CONFIG['allow_private_albums'] == 0) {
            if ($count > 0 || !empty($alb_stats[$alb_idx]['link_pic_count'])) {
                if (!empty($alb_thumb['filename'])) {
                    $picture = &$alb_thumb;
                } elseif ($alb_thumb['thumb'] < 0) {
                    $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight "
                        . "FROM {$CONFIG['TABLE_PICTURES']} "
                        . "WHERE ((aid = '{$alb_thumb['aid']}' $forbidden_set_string) $keyword) $approved "
                        . "ORDER BY RAND() LIMIT 0,1";
                    $result = cpg_db_query($sql);
                    $picture = mysql_fetch_assoc($result);
                    mysql_free_result($result);
                } else {
                    $picture = $last_pid_data[$alb_stat['last_pid']];
                }

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

4)

  $keyword = ($album['keyword'] ? "OR (keywords like '%".addslashes($album['keyword'])."%' $forbidden_set_string)" : '');
        if (!in_array($aid, $FORBIDDEN_SET_DATA) || $CONFIG['allow_private_albums'] == 0) { //test for visibility
            if ($album['pic_count'] > 0  || !empty($album['link_pic_count'])) {
                if (!empty($last_pid_data[$album['thumb']]['filename'])) {
                    $picture = $last_pid_data[$album['thumb']];
                } elseif ($album['thumb'] < 0) {
                    $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight "
                        . "FROM {$CONFIG['TABLE_PICTURES']} WHERE ((aid = '$aid' $forbidden_set_string) $keyword) $approved "
                        . "ORDER BY RAND() LIMIT 0,1";
                    $result = cpg_db_query($sql);
                    $picture = mysql_fetch_assoc($result);
                    mysql_free_result($result);
                } else {
                    $picture = $last_pid_data[$album['last_pid']];
                }
                $pic_url = get_pic_url($picture, 'thumb');
                if (!is_image($picture['filename'])) {
                    $image_info = cpg_getimagesize(urldecode($pic_url));
                    $picture['pwidth'] = $image_info[0];
                    $picture['pheight'] = $image_info[1];
                }




Also, I notice that

mysql_free_result($result);


is above

$pic_url = get_pic_url($picture, 'thumb');


in all cases.

What do you mean by your last instruction?



Thanks a lot

alcorjr

Sorry, this is the 3rd instance:


  $keyword = ($alb_thumb['keyword'] ? "OR (keywords like '%".addslashes($alb_thumb['keyword'])."%' $forbidden_set_string )" : '');
        if (!in_array($aid, $FORBIDDEN_SET_DATA) || $CONFIG['allow_private_albums'] == 0) {
            if ($count > 0 || !empty($alb_stats[$alb_idx]['link_pic_count'])) {
                if (!empty($alb_thumb['filename'])) {
                    $picture = &$alb_thumb;
                } elseif ($alb_thumb['thumb'] < 0) {
                    $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight "
                        . "FROM {$CONFIG['TABLE_PICTURES']} "
                        . "WHERE ((aid = '{$alb_thumb['aid']}' $forbidden_set_string) $keyword) $approved "
                        . "ORDER BY RAND() LIMIT 0,1";
                    $result = cpg_db_query($sql);
                    $picture = mysql_fetch_assoc($result);
                    mysql_free_result($result);
                } else {
                    $picture = $last_pid_data[$alb_stat['last_pid']];
                }

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

Αndré

You have to replace 3) and 4)

As you can see, there's no
mysql_free_result($result);
(directly) above that line, but a closing curly bracket. Alternatively just have a look at the functions those lines reside in.

alcorjr