warning: Division by zero in /usr/home/xyz/domains/myDomain/public_html/sporta/includes/image.inc on line 160.
warning: Division by zero in /usr/home/xyz/domains/myDomain/public_html/sporta/includes/image.inc on line 160.
Unable to create scaled Thumbnail image
The removal of the original file has failed.

CommentFileSizeAuthor
#6 image-223836.patch623 byteswww.richardsprojects.co.uk

Comments

yoroy’s picture

Title: Error by creating images » Division by zero warning in image.inc, no images created.
Priority: Normal » Critical

I get the same warning, except for the fourth, last line, mine says: "The selected file /bla/bla could not be copied."

- Images smaller than the thumbnail settings are no problem, they upload and display fine.
- anything above the max. thumbnail size gives the above warning, with one exception:

I set my thumbnail settings to scale and crop to 60x60px. I created square images of 59, 60, 61 and 62px.
- 59 & 60 px: all good
- 61px: some script seems to keep running, upload (or save?) never finishes. The browser stays responsive but never finishes loading
62px and more give the warning mentioned above. The new node is created, but without the image file.

This is on a local install under OS X,
Apache 1.3.33, PHP 5.1.6, Drupal6.1
from the Status Report:
File system Writable (public download method)
GD library bundled (2.0.28 compatible)
Image module directories Exists (sites/default/files/images)
Image toolkit The gd toolkit is installed

bump to critical for visibility (and general borkedness, for me at least :)

Thanks.

yoroy’s picture

janx: assigning a issue to yourself means you will try and fix it. Are you or were you just reporting?

I still get the warning with latest build, march 04.

bneijt’s picture

Hi readers,

Just wanted to mention that the given error occurs in Drupal (includes directory) and not the image module. It might even be a problem with gd not being installed as "@getimagesize" in images.inc:image_get_info() could just return false resulting in that the width and height of the image are not set.

If images.inc:image_scale_and_crop() would check the return value of image_get_info() it might all become allot clearer. Maybe this bug needs to be moved to the Drupal core??

tic2000’s picture

I had the same problem. Don't know what it's your case, but I had this problem when I set the "scale and crop image" option for one of the sizes.
The problem was in image.module on line 809:
$status = image_scale_and_crop($destination, $destination, $size['width'], $size['height']);
I changed the above to:
$status = image_scale_and_crop($original_path, $destination, $size['width'], $size['height']);
and all works fine now. The problem is that it passes twice the destination instead of the original path. The destination file doesn't exist yet, $info = image_get_info($source); returns NULL and $scale = max($width / $info['width'], $height / $info['height']); generates the error cause we have no $info['height'] or $info['width'].
Hope that helps.

www.richardsprojects.co.uk’s picture

I had the same problem and changing $destination to $original_path fixed it.

www.richardsprojects.co.uk’s picture

Status: Active » Needs review
StatusFileSize
new623 bytes

I've made a patch that implements tic2000's suggested fix in comment #4.

It's quite a simple, but I've not done a patch before, so can someone let me know it's okay.

fzwoch’s picture

The fix works fine for me too and seems pretty much sane.

The patch looks ok but I would have removed the redundant space right before the third argument too.

CNlQ8o’s picture

Status: Needs review » Reviewed & tested by the community

The patch works.

yesct’s picture

is this in the alpha release?

jimmyc’s picture

No, it's not in the alpha release (I'm using it) nor in 6.x-1.x-dev (from what others are saying).

Hetta’s picture

marked http://drupal.org/node/216773 as duplicate.

fzwoch’s picture

The patch seems to be included in 6.x-1.0-alpha2 (2008-Jun-16) as well as in 6.x-1.x-dev (2008-Jun-17).

Perhaps this can be closed?

drewish’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

yeah looks like this and #257167: Scale and crop not working are duplicates. since that got committed i'll mark this as a dupe.