Title: [Plugin: NextGEN Gallery] plugin generates wrong thumbnail size
Last modified: August 19, 2016

---

# [Plugin: NextGEN Gallery] plugin generates wrong thumbnail size

 *  Resolved [jimmyjjames](https://wordpress.org/support/users/jimmyjjames/)
 * (@jimmyjjames)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/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
 * [http://wordpress.org/extend/plugins/nextgen-gallery/](http://wordpress.org/extend/plugins/nextgen-gallery/)

Viewing 15 replies - 1 through 15 (of 20 total)

1 [2](https://wordpress.org/support/topic/plugin-nextgen-gallery-plugin-generates-wrong-thumbnail-size/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-nextgen-gallery-plugin-generates-wrong-thumbnail-size/page/2/?output_format=md)

 *  Thread Starter [jimmyjjames](https://wordpress.org/support/users/jimmyjjames/)
 * (@jimmyjjames)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-plugin-generates-wrong-thumbnail-size/#post-1561142)
 * 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
 *  Thread Starter [jimmyjjames](https://wordpress.org/support/users/jimmyjjames/)
 * (@jimmyjjames)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-plugin-generates-wrong-thumbnail-size/#post-1561341)
 * 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
 *  [swam2222](https://wordpress.org/support/users/swam2222/)
 * (@swam2222)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-plugin-generates-wrong-thumbnail-size/#post-1561542)
 * 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
 *  [PaulD](https://wordpress.org/support/users/paulio51/)
 * (@paulio51)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-plugin-generates-wrong-thumbnail-size/#post-1561544)
 * I believe he meant wp-content\plugins\nextgen-gallery\admin\functions.php
 * Paul
 *  [swam2222](https://wordpress.org/support/users/swam2222/)
 * (@swam2222)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-plugin-generates-wrong-thumbnail-size/#post-1561546)
 * Hi Paulio,
 * Thanks for that.
 * cheers
 * Sam
 *  Thread Starter [jimmyjjames](https://wordpress.org/support/users/jimmyjjames/)
 * (@jimmyjjames)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-plugin-generates-wrong-thumbnail-size/#post-1561552)
 * 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
 *  Thread Starter [jimmyjjames](https://wordpress.org/support/users/jimmyjjames/)
 * (@jimmyjjames)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-plugin-generates-wrong-thumbnail-size/#post-1561554)
 * 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 alekz
 *  [srichand](https://wordpress.org/support/users/srichand/)
 * (@srichand)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-plugin-generates-wrong-thumbnail-size/#post-1561565)
 * Hi,
 * Thanks for ur valuable posts……
    keep on the good work
 *  [srichand](https://wordpress.org/support/users/srichand/)
 * (@srichand)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-plugin-generates-wrong-thumbnail-size/#post-1561566)
 * hi,
 * why lightbox effect is not working for me……???
    any suggestions!!!!!!!!
 *  [thedrewseum](https://wordpress.org/support/users/thedrewseum/)
 * (@thedrewseum)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-plugin-generates-wrong-thumbnail-size/#post-1561567)
 * 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.
 *  Thread Starter [jimmyjjames](https://wordpress.org/support/users/jimmyjjames/)
 * (@jimmyjjames)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-plugin-generates-wrong-thumbnail-size/#post-1561568)
 * can u tell me the exact size of your photos, so i can test it?
 *  [tjsherrill](https://wordpress.org/support/users/tjsherrill/)
 * (@tjsherrill)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-plugin-generates-wrong-thumbnail-size/#post-1561588)
 * 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
 *  [thedrewseum](https://wordpress.org/support/users/thedrewseum/)
 * (@thedrewseum)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-plugin-generates-wrong-thumbnail-size/#post-1561596)
 * > 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.
 *  Thread Starter [jimmyjjames](https://wordpress.org/support/users/jimmyjjames/)
 * (@jimmyjjames)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-plugin-generates-wrong-thumbnail-size/#post-1561603)
 * 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
 *  Thread Starter [jimmyjjames](https://wordpress.org/support/users/jimmyjjames/)
 * (@jimmyjjames)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-plugin-generates-wrong-thumbnail-size/#post-1561604)
 * here the link to the issue and patch
    [http://code.google.com/p/nextgen-gallery/issues/detail?id=308](http://code.google.com/p/nextgen-gallery/issues/detail?id=308)

Viewing 15 replies - 1 through 15 (of 20 total)

1 [2](https://wordpress.org/support/topic/plugin-nextgen-gallery-plugin-generates-wrong-thumbnail-size/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-nextgen-gallery-plugin-generates-wrong-thumbnail-size/page/2/?output_format=md)

The topic ‘[Plugin: NextGEN Gallery] plugin generates wrong thumbnail size’ is closed
to new replies.

 * ![](https://ps.w.org/nextgen-gallery/assets/icon-256x256.png?rev=2083961)
 * [Photo Gallery, Sliders, Proofing and Themes - NextGEN Gallery](https://wordpress.org/plugins/nextgen-gallery/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/nextgen-gallery/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/nextgen-gallery/)
 * [Active Topics](https://wordpress.org/support/plugin/nextgen-gallery/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/nextgen-gallery/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/nextgen-gallery/reviews/)

 * 20 replies
 * 8 participants
 * Last reply from: [standardspace](https://wordpress.org/support/users/standardspace/)
 * Last activity: [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-nextgen-gallery-plugin-generates-wrong-thumbnail-size/page/2/#post-1561684)
 * Status: resolved