ThumbGeneratorAdapter bugging?

Dec 21, 2008 at 9:30 PM

My problem: Resizing isn't working, more specifically: MaximumWidth isn't working if the images (only tried jpg) height is higher then it's width.
Some examples with maxwidth and height set to 150:
Original image: 500x200 (higher height then width)
Thumb: 150x200 (should be 90x150)

Original image: 200x500 (lower height then width)
Thumb: 150x90 (as it should)

My code:
MaxFileSizeReachedMessage="Filen får högst vara {0} stor."
AllowedFileTypes="Tillåtna filtyper:*.rtf;*.doc;*.xls;*.docx;*.jpg;*.jpeg;*.png;*.gif;*.txt;"
<fjx:ThumbGeneratorAdapter runat="server" Extensions="jpg;jpeg;png;gif" MaximumHeight="150" MaximumWidth="150" />

(foldername is set in codebehind)

Dec 21, 2008 at 11:32 PM
Hi Kani,

I just tested it and I see that the adapters work fine. It must be something you do on  the code behind.

For example I see that you don't use Suffix or Prefix properties of the Thumb Generator adapter so if you store thumbs in the same folder as images, the images one can override the other, but even then the hight - width ratio will be the same. So I have no idea what is your problem. I cannot repeat it. If you can isolate the problem and send the code I can look at it.
Dec 22, 2008 at 4:44 PM

Here is an example of what my code looks like, and also including

If you want to try upload to my server and see the result you can use: <- uploader <- uploaded files -<- thumbnails

Dec 22, 2008 at 5:18 PM
That is strange cause on my computer your code works fine.

I see that you use version 2.0.3265. Can you try with the latest version, though I didn't change thumb generator for a long time.

Did you see the same problem on different computers?

It may be that you have different version of GDI...
Dec 22, 2008 at 6:05 PM

Yes I suspected it to be the version too.

I thought I'm using the latest version, I took it from the download button at

Where can I find a newer version?

Dec 22, 2008 at 6:17 PM

Ok now I found it and it seems to be working. So I probably had an old version.

The "Download Now" button I mentioned above seems to link to an old version.

Dec 22, 2008 at 6:33 PM
OK it's still strange as I did not change thumb generator recently...
Dec 22, 2008 at 6:59 PM

My bad.. actually, this is getting a bit strange.

I downloaded it again and put it in the bin folder, tried upload some files and it worked..

But now it's not working again, I even tried download the latest source and compile it myself. But I keep getting the same problem... just no idea why it worked for a few sec back there..

Dec 22, 2008 at 7:36 PM
Edited Dec 23, 2008 at 9:31 AM

I checked the source and foundthe part that handles resizing, and it wasn't coded correctly:

I changed

double ratio = image.Width / (double)image.Height;
int width = maxWidth;
int height = (int)Math.Round(width / ratio);
if (height > maxHeight)
height = maxHeight;
width = (int)Math.Round(image.Height * ratio);


double ratio;
int height;
int width;
if (image.Width > image.Height)
ratio = image.Width / (double)image.Height;
width = maxWidth;
height = (int)Math.Round(width / ratio);
if (height > maxHeight)
height = maxHeight;
width = (int)Math.Round(image.Height * ratio);
ratio = image.Height / (double)image.Width;
height = maxHeight;
width = (int)Math.Round(height / ratio);
if (width > maxWidth)
width = maxWidth;
height = (int)Math.Round(image.Width * ratio);

I'm not sure if it's the smoothest way to do it but it solved my problem.
Note that the bug only happened with images with higher height then width.. now I just added an if that checks if width or heightis higher and handles the resizing accordingly.

Dec 22, 2008 at 9:03 PM
Edited Dec 22, 2008 at 9:06 PM
OK Thanks I will check that later, may be the algorithm need optimization
Dec 23, 2008 at 9:59 AM
Yea, and thanks for the help :)
Jan 26, 2009 at 1:41 PM
Thumbs are not created if uploading files with spaces in the name...
Could be a solution replace spaces with _ char?
Jan 26, 2009 at 6:52 PM
There is no problem with spaces.

Most probably you use the same folder for thumbs and files and you don't use Prefix or Suffix so one overrides the other.