NextGEN Gallery v2 Resize Issue Persists

If you are concerned about the quality of your NextGEN Gallery v2.x resized images, this should be of particular interest to you.

Some months ago I contacted Photocrati to ask them how, in version 2.x, developers could retrieve the “actual” dimensions of a resized image. In the past, after resizing an image we could use PHP’s getimagesize() function on the resulting file, but in v2.x image resizing is dynamic and those resized images may not be available on disk. I had some concerns between the expected / calculated image dimensions, those returned by NGG v2.x’s methods / functions, and the actual image retrieved by the URL. All 3 dimensions were different! A resized uncropped image which should have been 300x200px, was reported as being 300x199px by the NGG methods / functions, and the image retrieved by URL was 298x199px!

This may not sound like much, but a few pixels here and there can lead to image distortion when rendered by browsers, alignment issues in page layouts, and failures when working with minimum image dimensions (for example, Facebook ignores images smaller than 200x200px).

Although Photocrati’s first-line support was helpful, this matter required the attention of Photocrati’s DEV team, which were not responsive. After waiting several weeks for the matter to be escalated, I paid for Pro support and re-submitted my question / issues again. Photocrati’s first-line support where responsive, but could not get the DEV team to look at this. After the holidays I asked them to escalate or refund my Pro support. The matter was finally escalated and I was forwarded some code to generate images and get information on the result. Unfortunately, this code was very similar to the code I’d already submitted as an example, so no help at all.

I’m pretty sure Photocrati’s DEV team is swamped by v2.x bugs — we all remember the massive failure of v2.x’s release — so I don’t blame them for wanting to turn a blind eye to another bug, but they should have at least recognized the seriousness of the issue. I explained the problem several times — some of their first-line support understood the problem, and some did not (or would not) understand.

Considering my experience with this, I don’t expect the issue to be resolved any time soon, so I’ll document the problem here for other NextGEN Gallery v2.x users (feel free to borrow any of this text for your bug reports). The problem should be apparent for any uncropped image where the resized number of pixels is not a perfect integer. For example, an image of 2048x1365px downsized to 300x300px is 300×199.951174px (300x200px rounded). I expect there’s a bug in NGG v2.x’s rounding, so the size comes out to 300x199px instead. Those dimensions must then be used to scale the image, which creates a final image of 298x199px. Why they would choose to do it this way is a mystery to me — it seems the image should be resized first, then it’s dimensions reported, not the other way around (there’s a reason the horse goes before the cart).

Here’s some example code to re-create the issue:

Find this content useful? Share it with your friends!