cannot view original size, always max width

goodyer - January 19, 2009 - 21:06
Project:Brilliant Gallery
Version:6.x-3.0
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

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

#1

gilgabar - January 20, 2009 - 17:23
Category:support request» bug report

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.

#2

gilgabar - January 23, 2009 - 01:11

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.

#3

mike69 - January 24, 2009 - 23:03

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

#4

albert.pratama - March 31, 2009 - 08:49

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.

#5

jefftrnr - September 9, 2009 - 18:48

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;
    }

 
 

Drupal is a registered trademark of Dries Buytaert.