when using lightbox2 and brilliant gallery and i expand the image, it always expands the image to the maximumm width size in the brilliant gallery configuration settings. i cannot view the image in its original state.

example when i set the max width option to 1920. i proceed to view a 'wallpaper' in expanded mode (which is 1280x1024) it will always blow it up to a width of 1920 which does not work when trying to display a wallpaper for a user to download

Comments

gilgabar’s picture

Category:support» bug

I'm having the same issue. I just upgraded from 6.x-1.2 to 6.x-3.0. It did not have any problem with image sizing in the previous version, so it seems likely it is due to a bug introduced in the most recent version. I don't have time to troubleshoot at the moment, so hopefully someone else can figure it out.

gilgabar’s picture

It looks like the problem is around lines 750 -757 in brilliant_gallery.module:

#if ($smallenough === true) {
      #  $result .= '<a href="'. $fullimgpath .'"';
      #}
      #else {
        # Important to begin with the "/" otherwise thumbnails in non-root folders fail. See http://drupal.org/node/175292
        #$result .= '<a href="' . $modulepath .'/image.php?imgp=' . base64_encode( $absolpath . '/' . $retval[$poct-1] ) . '&amp;imgw=' . $imgwbig . '&amp;imgh=' . $imghbig . '"'; #&dummy=.jpg
        #&dummy=.jpg
        $result .= '<a href="'. $modulepath .'/image.php?imgp='. base64_encode($absolpath .'/'. $retval[$poct - 1]) .'&imgw='. $imgwbig .'&imgh='. $imghbig .'"';
      #}

It looks like in the previous versions there was some logic there that decided whether the image was bigger than the maxwidth. If it was, then it applied the maxwidth dimensions instead of the original dimensions, effectively shrinking it to fit. Otherwise it would use the original dimensions. It looks like it is commented out in the current version which causes the maxwidth dimension to always be applied, effectively blowing it up if it is smaller.

While uncommenting it doesn't appear to restore functionality entirely, it is possible to get the old functionality back if you uncomment line 751 and comment out line 757. It will no longer apply the maxwidth to larger images, but if you have either manually scaled all your images anyway or are using the auto scaling feature in lightbox, then it should not be a problem and good enough for the short term until someone can make a real fix.

mike69’s picture

Hi have got the same problem and the uncommenting does not help. It is not enough, I found some more places which have to be uncommented:

Look into the functions.inc and locate "function load_dir_to_array" and uncomment from:

    if (($temp[0] - $temp[1]) >= 0) {
      // This is a horizontal image
      $retval_dimensions[$poct]['imgw'] = $imagewidth;
      $retval_dimensions[$poct]['imgh'] = round(($temp[1] / $temp[0]) * $imagewidth);
#      if ($temp[0] > $fullresolutionmaxwidth) {
        $retval_dimensions[$poct]['imgwbig'] = $fullresolutionmaxwidth;
        $retval_dimensions[$poct]['imghbig'] = round(($temp[1] / $temp[0]) * $fullresolutionmaxwidth);
#      }
#      else {
#        $retval_dimensions[$poct]['smallenough'] = true;
#      }
      #$result .= $imgw . ' / ' . $imgh;
    }
    else {
      // This is a vertical image
      $retval_dimensions[$poct]['imgw'] = round(($temp[0] / $temp[1]) * ($temp[0] / $temp[1]) * $imagewidth);
      $retval_dimensions[$poct]['imgh'] = round(($temp[0] / $temp[1]) * $imagewidth);
#      if ($temp[0] > $fullresolutionmaxwidth) {
        $retval_dimensions[$poct]['imgwbig'] = round(($temp[0] / $temp[1]) * ($temp[0] / $temp[1]) * $fullresolutionmaxwidth);
        $retval_dimensions[$poct]['imghbig'] = round(($temp[0] / $temp[1]) * $fullresolutionmaxwidth);
#      }
#      else {
#        $retval_dimensions[$poct]['smallenough'] = true;
#      }
      #$result .= $imgw . ' / ' . $imgh;
    }

into:

    if (($temp[0] - $temp[1]) >= 0) {
      // This is a horizontal image
      $retval_dimensions[$poct]['imgw'] = $imagewidth;
      $retval_dimensions[$poct]['imgh'] = round(($temp[1] / $temp[0]) * $imagewidth);
      if ($temp[0] > $fullresolutionmaxwidth) {
        $retval_dimensions[$poct]['imgwbig'] = $fullresolutionmaxwidth;
        $retval_dimensions[$poct]['imghbig'] = round(($temp[1] / $temp[0]) * $fullresolutionmaxwidth);
      }
      else {
        $retval_dimensions[$poct]['smallenough'] = true;
      }
      #$result .= $imgw . ' / ' . $imgh;
    }
    else {
      // This is a vertical image
      $retval_dimensions[$poct]['imgw'] = round(($temp[0] / $temp[1]) * ($temp[0] / $temp[1]) * $imagewidth);
      $retval_dimensions[$poct]['imgh'] = round(($temp[0] / $temp[1]) * $imagewidth);
      if ($temp[0] > $fullresolutionmaxwidth) {
        $retval_dimensions[$poct]['imgwbig'] = round(($temp[0] / $temp[1]) * ($temp[0] / $temp[1]) * $fullresolutionmaxwidth);
        $retval_dimensions[$poct]['imghbig'] = round(($temp[0] / $temp[1]) * $fullresolutionmaxwidth);
      }
      else {
        $retval_dimensions[$poct]['smallenough'] = true;
      }
      #$result .= $imgw . ' / ' . $imgh;
    }

After that, I can see now small images in their original size ...

Ciao,
Mike

apprayo’s picture

Changing the code as suggested by both gilgabar and mike69 didn't work for me.

I found another thing to do. I did mike69 suggestion, plus this one:

Change this code in brilliant_gallery.module (at about line 734)

        $result .= '<a href="'. $modulepath .'/image.php?imgp='. base64_encode($absolpath .'/'. $retval[$poct - 1]) .'&imgw='. $imgwbig .'&imgh='. $imghbig .'"';

Into this code:

        $temp_size = getimagesize($absolpath .'/'. $retval[$poct - 1]);
        $result .= '<a href="'. $modulepath .'/image.php?imgp='. base64_encode($absolpath .'/'. $retval[$poct - 1]) .'&imgw='. $temp_size[0] .'&imgh='. $temp_size[1] .'"';

By this way, we set the images in the browser (I use lightbox) in their original size.
Hope this helps.

jefftrnr’s picture

The code that was commented out would be useful if it used the $retval_dimensions array, which may have been introduced in the previous change? Here is my "patch" which seemed to fix the problem.

This may be a better fix than comment #4 since it still preserves the code that sets an image that's too large to the max-width size. Hopefully it's closer to what the author intended. Please test it and if we can make it into a patch, possibly we'll something like this fix it in the next version.

# lines 64-83 of functions.inc replaced with the lines below
    if (($temp[0] - $temp[1]) >= 0) {
      // This is a horizontal image
      $retval_dimensions[$poct]['imgw'] = $imagewidth;
      $retval_dimensions[$poct]['imgh'] = round(($temp[1] / $temp[0]) * $imagewidth);
      if ($temp[0] > $fullresolutionmaxwidth) {
        $retval_dimensions[$poct]['imgwbig'] = $fullresolutionmaxwidth;
        $retval_dimensions[$poct]['imghbig'] = round(($temp[1] / $temp[0]) * $fullresolutionmaxwidth);
      }
      else {
        $retval_dimensions[$poct]['imgwbig'] = $temp[0];
        $retval_dimensions[$poct]['imghbig'] = $temp[1];
        $retval_dimensions[$poct]['smallenough'] = true;
      }
      #$result .= $imgw . ' / ' . $imgh;
    }
    else {
      // This is a vertical image
      $retval_dimensions[$poct]['imgw'] = round(($temp[0] / $temp[1]) * ($temp[0] / $temp[1]) * $imagewidth);
      $retval_dimensions[$poct]['imgh'] = round(($temp[0] / $temp[1]) * $imagewidth);
      if ($temp[0] > $fullresolutionmaxwidth) {
        $retval_dimensions[$poct]['imgwbig'] = round(($temp[0] / $temp[1]) * ($temp[0] / $temp[1]) * $fullresolutionmaxwidth);
        $retval_dimensions[$poct]['imghbig'] = round(($temp[0] / $temp[1]) * $fullresolutionmaxwidth);
      }
      else {
        $retval_dimensions[$poct]['imgwbig'] = $temp[0];
        $retval_dimensions[$poct]['imghbig'] = $temp[1];
        $retval_dimensions[$poct]['smallenough'] = true;
      }
      #$result .= $imgw . ' / ' . $imgh;
    }
drewbul’s picture

Version:6.x-3.0» 6.x-3.6

In the latest version of BG (6.x-3.6), which was released (2009-Oct-29) after the last comment here (2009-Sep-09), the problem still exists, but all the suggested patches either are not applicable or do not work. I would gladly sacrifice this functionality at all, as suggested in comment #2. I would also be happy if the lightbox simply had fullimgpath as src (no resizing - less server load). Tried to do that but failed - no PHP skill :(.
Please suggest a solution.

DreeStyler’s picture

Hi,
maybe too later, but for another dummies like me:
I cannot find any patches right now.
Even though the version(Brilliant gallery 6.x-3.6) matches version mentioned in this solutions, it is not he same. The lines 750-757 do not matches with line numbers of "newer version", but code is still the same in the response of #2 Gilgabar.

This will do that link generated on all of pictures will be headed to original path of picture(e.g. /files/bg_images/kyberia_vykradacka/art/1194216322_06(2).jpg) instead of generating link with attributes for resizing influenced by max width.

If you want to repair this bug, replace this piece of code with code above:

#if ($smallenough != true) {
$result .= '

AdamTS’s picture

Hello, I basically just tossed out the resizing feature because I pre-scale my images the way I need them anyway. See below (starting at line 38 of functions.inc).

    if (($temp[0] - $temp[1]) >= 0) {
      // This is a horizontal image
      $retval_dimensions[$poct]['imgw'] = $imagewidth;
      $retval_dimensions[$poct]['imgh'] = round(($temp[1] / $temp[0]) * $imagewidth);

# ########################
# MODIFIED BY ASH 20101015
# ########################
#      $retval_dimensions[$poct]['imgwbig'] = $fullresolutionmaxwidth;
#      $retval_dimensions[$poct]['imghbig'] = round(($temp[1] / $temp[0]) * $fullresolutionmaxwidth);
      $retval_dimensions[$poct]['imgwbig'] = $temp[0];
      $retval_dimensions[$poct]['imghbig'] = $temp[1];
# ########################

    }
    else {
      // This is a vertical image
      if ($imagecrop){
        $retval_dimensions[$poct]['imgw'] = round(($temp[0] / $temp[1]) * $imagewidth);
        $retval_dimensions[$poct]['imgh'] = $imagewidth;
      }
      else {
        $retval_dimensions[$poct]['imgw'] = round(($temp[0] / $temp[1]) * ($temp[0] / $temp[1]) * $imagewidth);
        $retval_dimensions[$poct]['imgh'] = round(($temp[0] / $temp[1]) * $imagewidth);
      }

# ########################
# MODIFIED BY ASH 20101015
# ########################
#      $retval_dimensions[$poct]['imgwbig'] = round(($temp[0] / $temp[1]) * ($temp[0] / $temp[1]) * $fullresolutionmaxwidth);
#      $retval_dimensions[$poct]['imghbig'] = round(($temp[0] / $temp[1]) * $fullresolutionmaxwidth);
      $retval_dimensions[$poct]['imgwbig'] = $temp[0];
      $retval_dimensions[$poct]['imghbig'] = $temp[1];
# ########################

    }

Adam
-----------
www.mindwave.ch

postak’s picture

Version:6.x-3.6» 7.x-1.2

seems that the issue is present also in 7.x-1.2 version
will try some workarounds...

EDIT:
seems that workaround #8 from AdamTS works
btw, if you use Picasa as a source, by default it sends quite small pictures via RSS feed, so the http call needs to be extended with parameter imgmax, e.g. "&imgmax=1600" (leaves smaller originals and crops big pictures)

EDIT2:
I don't know PHP, but it seems to me, that working (and corrected) solution could be:

...
      if ((($temp[0] - $temp[1]) >= 0) OR $maximumnumbertoshow == 1) {
        // This is a horizontal image.
        // Treat single images just as horizontal images (no need to fit their height to the height of horizontals)! The specified width of an image is authoritative for both horizontal images and also vertical if they show alone.
        #if ($imagecrop == 'yes' and $maximumnumbertoshow <> 1){
        if ($imagecrop == 'yes') {
          $retval_dimensions[$poct]['imgw'] = $imagewidth;
          $retval_dimensions[$poct]['imgh'] = $imagewidth;
        } else {
          $retval_dimensions[$poct]['imgw'] = $imagewidth;
          $retval_dimensions[$poct]['imgh'] = round(($temp[1] / $temp[0]) * $imagewidth);
          #watchdog('Brilliant Gal','1imgw: '.$imagewidth.'/'.$imagecrop);
        }
      } else {
        // This is a vertical image
        if ($imagecrop == 'yes') {
          $retval_dimensions[$poct]['imgw'] = round(($temp[0] / $temp[1]) * $imagewidth);
          $retval_dimensions[$poct]['imgh'] = $imagewidth;
        } else {
          $retval_dimensions[$poct]['imgw'] = round(($temp[0] / $temp[1]) * ($temp[0] / $temp[1]) * $imagewidth);
          $retval_dimensions[$poct]['imgh'] = round(($temp[0] / $temp[1]) * $imagewidth);
          #watchdog('Brilliant Gal','2imgw: '.$imagewidth.'/'.$imagecrop);
          #watchdog('Brilliant Gal','2imgw: '.$temp[0].'-'.$temp[1]);
        }
      }
      // set maximum width for big pictures
      if ($temp[0] > $fullresolutionmaxwidth) {
        $retval_dimensions[$poct]['imgwbig'] = $fullresolutionmaxwidth;
        $retval_dimensions[$poct]['imghbig'] = round(($temp[1] / $temp[0]) * $fullresolutionmaxwidth);
      } else {
        $retval_dimensions[$poct]['imgwbig'] = $temp[0];
        $retval_dimensions[$poct]['imghbig'] = $temp[1];       
      }
      // In $imagemaxh collect the maximum vertical size of the gallery.
...