[Plugin: NextGEN Gallery] plugin generates wrong thumbnail size
-
Hello,
i am using wordpress 3.0 and the NextGEN Gallery 1.5.5 – plugin. for some reasons this plugin generates wrong thumbnail size. for example: in the options i set “width x height” to “150 x 105” and ckeck the option “ignore image propotions”.
then i upload an image with a dimension of 900×624 and the plugin generates a thumbnail with a dimension of 147×105. but it should be 150×105.
has someone a solution, or is a bugfix comming?
thanx in advance for help,
alekz
-
hi,
its me again.i looked into the source (lib/gd.thumbnail.inc.php). following things i have noticed:
1. the “resize” function is called, but perhaps “resizeFix” should be called!?
2. param $maxWidth is not set (but should be 150)
3. calcHeight function is called and calculates for the width proportionally the value 147 (instead the new imagesize should be calculated to 150×107 and afterwards be cropped to 150×105)can someone approve this false behaviour?
does someone know, why the param $maxWidth of the “resize”-function is not set?
is someone sure, if the “resize” or “resizeFix” function should be called.this excellent plug-in is unfortunately useless with this bug.
alekz
Hi,
so my solution is:
in the file functions.php in line 272 i replace
if ($ngg->options['thumbfix']) { // check for portrait format if ($thumb->currentDimensions['height'] < $thumb->currentDimensions['width']) { // first resize to the wanted width $thumb->resize($ngg->options['thumbwidth'], 0); // get optimal y startpos $ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2; $thumb->crop(0, $ypos, $ngg->options['thumbwidth'],$ngg->options['thumbheight']); } else { // first resize to the wanted height $thumb->resize(0, $ngg->options['thumbheight']); // get optimal x startpos $xpos = ($thumb->currentDimensions['width'] - $ngg->options['thumbwidth']) / 2; $thumb->crop($xpos, 0, $ngg->options['thumbwidth'],$ngg->options['thumbheight']); } //this create a thumbnail but keep ratio settings } else { $thumb->resize($ngg->options['thumbwidth'],$ngg->options['thumbheight']); }
with
if ($ngg->options['thumbfix']) { // check for portrait format // first resize to the wanted width $thumb->resize($ngg->options['thumbwidth'], 0); // get optimal y startpos $ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2; $thumb->crop(0, $ypos, $ngg->options['thumbwidth'],$ngg->options['thumbheight']); //this create a thumbnail but keep ratio settings } else { $thumb->resize($ngg->options['thumbwidth'],$ngg->options['thumbheight']); }
and it seems to work.
maybe alex rabe could verify this und implement this bugfix into the plugin.
alekz
Hi Jimmy,
Which file does this replacement code go into?
My themes function.php doesn’t go up to line 272 and doesn’t contain any of the code which you replace.
thanks
Sam
I believe he meant wp-content\plugins\nextgen-gallery\admin\functions.php
Paul
Hi Paulio,
Thanks for that.
cheers
Sam
Sorry for the late reply! Don’t we get mails, if a reply is sent on a thread in this forum?
yes i meant indeed the wp-content\plugins\nextgen-gallery\admin\functions.php file.
works it for you too?
jimmy
Ok,
hi again. The last solution wasn’t right. I recognized it just now. But here is the final solution, and for me and the images i have it works.so again go to the wp-content\plugins\nextgen-gallery\admin\functions.php, line 272 and replace
if ($ngg->options['thumbfix']) { // check for portrait format if ($thumb->currentDimensions['height'] < $thumb->currentDimensions['width']) { // first resize to the wanted width $thumb->resize($ngg->options['thumbwidth'], 0); // get optimal y startpos $ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2; $thumb->crop(0, $ypos, $ngg->options['thumbwidth'],$ngg->options['thumbheight']); } else { // first resize to the wanted height $thumb->resize(0, $ngg->options['thumbheight']); // get optimal x startpos $xpos = ($thumb->currentDimensions['width'] - $ngg->options['thumbwidth']) / 2; $thumb->crop($xpos, 0, $ngg->options['thumbwidth'],$ngg->options['thumbheight']); } //this create a thumbnail but keep ratio settings } else { $thumb->resize($ngg->options['thumbwidth'],$ngg->options['thumbheight']); }
with
if ($ngg->options['thumbfix']) { // check for portrait format $wratio = $ngg->options['thumbwidth'] / $thumb->currentDimensions['width']; $hratio = $ngg->options['thumbheight'] / $thumb->currentDimensions['height']; if ($wratio > $hratio) { // first resize to the wanted width $thumb->resize($ngg->options['thumbwidth'], 0); // get optimal y startpos $ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2; $thumb->crop(0, $ypos, $ngg->options['thumbwidth'],$ngg->options['thumbheight']); } else { // first resize to the wanted height $thumb->resize(0, $ngg->options['thumbheight']); // get optimal x startpos $xpos = ($thumb->currentDimensions['width'] - $ngg->options['thumbwidth']) / 2; $thumb->crop($xpos, 0, $ngg->options['thumbwidth'],$ngg->options['thumbheight']); } //this create a thumbnail but keep ratio settings } else { $thumb->resize($ngg->options['thumbwidth'],$ngg->options['thumbheight']); }
i hope it works for you too, and it would be nice if this bugfix would be implemented in the original plugin, so we dont have to reimplement it everytime a new version of the plug in comes out.
cu,
jimmy aka alekzHi,
Thanks for ur valuable posts……
keep on the good workhi,
why lightbox effect is not working for me……???
any suggestions!!!!!!!!Unfortunately this fix didn’t work for me :/ Photos with a size ratio that is slightly ‘off’ still generate smaller thumbnails. Hopefully this will be fixed soon, it’s the only problem I have with this amazing gallery plug-in.
can u tell me the exact size of your photos, so i can test it?
Just to give a bump to this post. JimmyJames solution worked for me. I replaced the lines and things are working better. Cropping is delivering better results.
thanks
can u tell me the exact size of your photos, so i can test it?
Jimmy, my thumbs are 80×100. The photos themselves are a variety of sizes.
hi thedrewseum,
i can’t reproduce the problem with the target thumbnail size of 80×100 pixels. have you checked the option “Set fix dimension”?
I have just committed a patch to googlecode for this problem. Hopefully it will be applied in the final version 1.6.0.
alekz
here the link to the issue and patch
http://code.google.com/p/nextgen-gallery/issues/detail?id=308
- The topic ‘[Plugin: NextGEN Gallery] plugin generates wrong thumbnail size’ is closed to new replies.