Division by zero in theme_image_style_preview after moving to production server Warning: Division by zero in theme_image_style_preview() (line 804 of
  /var/www/html/modules/image/image.admin.inc). 
  
  Warning: array_intersect_key(): Argument #1 is not an array in
  theme_image_style_preview() (line 806 of
  /var/www/html/modules/image/image.admin.inc).


I am receiving the above errors when I view several of the "stock" image styles on my site. I just moved my site from a development server to a production server, and the error does not occur on the development server version. I checked the directory permissions on the production server, and they appear to be consistent with the development server's permissions.

One really strange thing occurs when I view the source on the "preview image" in the admin back-end of one of those styles that has the issue. When I do, it shows the following path being called (which is, of course, not a valid path):

http://mysite.com/sites/default/files/styles/large/public/modules/image/sample.png?cache_bypass=1399676683

The "sites/default/files/styles/large/public/" part seems to be part of the issue, but I am not sure how that got there. All of my custom image styles work fine.

Thanks!
Apparently it is not safe to chmod files to 777.

A preferred way is to chmod files to 644, directories to 755 and set the ownership to the webserver, so the webserver can write files.

Here's a script for Ubuntu:

# Change directory permissions to 755.
find sites/default/files -type d -exec chmod 755 {} +
# Change folder permissions to 644.
find sites/default/files -type f -exec chmod 644 {} +
# Set ownership to webserver.
chown -R www-data:www-data sites/default/files


Learn more on - Recommended directory permissions.