Image Upload: Warning: Division by zero

4 posts by 3 authors in: Forums > CMS Builder
Last Post: April 20, 2010   (RSS)

By theclicklab - April 15, 2010

Hi, we just started getting this error for a few images:

Warning: Division by zero in /home/luxurychartergroup/luxurychartergroup.com/cms/lib/menus/default/common.php on line 142

Could it be corrupt images as its only a few of them that have issues. I have attached two of the suspect images.

FYI, I did find a reference to this error in an earlier post here: http://www.interactivetools.com/forum/gforum.cgi?post=75029;search_string=Warning%3A%20Division%20by%20zero;#75029

We did upgrade to version 2.03 recently as well.

Re: [Jason] Image Upload: Warning: Division by zero

By Chris - April 17, 2010

Hi aquaman,

I've done some further research on this.

It seems that those two JPEGs are actually slightly "corrupt", but most software is wise enough to just ignore the minor problem. Unfortunately, GD (which is the library that PHP uses for images) is really picky about this minor problem. I was able to get PHP to cough up this about cosmos-5.jpg:

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg, libjpeg: recoverable error: Corrupt JPEG data: 2781 extraneous bytes before marker 0xed

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: 'C:\Users\Chris\Desktop\cosmos-5.jpg' is not a valid JPEG file


And yet, they work fine in web browsers and probably everywhere else (except possibly GIMP, from what I've read.) *sigh*

I think I may have found a work-around, but it's going to take some further research.

In the meantime, please follow Jason's advice. If you're using Windows and don't have a photo editor, I recommend the free "Paint .NET" which does a pretty good job of providing standard photo-editing features.

P.S. How were those two JPEGs created? If you have any control over the process, you may consider upgrading the software that was used in their creation or trying out different software.

I hope this helps! Please let us know if you have any questions.
All the best,
Chris

Re: [chris] Image Upload: Warning: Division by zero

By Chris - April 20, 2010

Hi aquaman,

Unfortunately, my "workaround" was crashing Apache when I uploaded certain files. Crashing webservers is generally considered bad form, so I'm abandoning that approach.

The problem comes down to certain Canon cameras and PHP, as bizarre as that may seem.

The next beta of CMS Builder will no longer suffer a "division by zero" error when a corrupt JPEG is uploaded, but such photos will not be thumbnailed and their heights and widths will not be known.

Sorry we couldn't be of more help. Please let us know if you have any questions.
All the best,
Chris