I think there is problem in webhosting. Partial solution is mentioned in this thread Unable to create thumbnail image, but for me is impossible recompile PHP on my webhosting. I have found another (and this might be final) solution. I discover problem in function image_scale() in DRUPAL includes/image.inc - if paths $source is equal with path $destination there is no problem with resize image (in user profile module i have no problem with upload and resize new user image). If these paths are not equal i get always error like:

* warning: imagejpeg(): Unable to access files/obrazky/temp/rozhovor2.thumbnail.jpg in /data/web/webspace/02/27/00/0500002702/kope-vas-muza/includes/image.inc on line 300.
    * warning: imagejpeg(): Invalid filename 'files/obrazky/temp/rozhovor2.thumbnail.jpg' in /data/web/webspace/02/27/00/0500002702/kope-vas-muza/includes/image.inc on line 300.
    * Unable to create thumbnail image

I give idea use touch() PHP function for create new (empty) file before is image resized. I have rewrite image_scale() function from

function image_scale($source, $destination, $width, $height) {
	
  $info = image_get_info($source);
  ...

to

function image_scale($source, $destination, $width, $height) {
  // in some web hosting there is problem with create file with new filename through 
  // image_scale function. If file exists then is new image (with name $destination) 
  // created without problem
  if (!file_exists($destination)) touch($destination);
	
  $info = image_get_info($source);
  ...

and now thumbnail and preview images are created without problem in my webhosting .

Comments

havran’s picture

Sorry i forget some important info - i use DRUPAL 4.7rc3 and latest Image module from cvs. Excuse me...

Jep’s picture

A better way to correct this bug is changing the image_gd_close function :

function image_gd_close($res, $destination, $extension) {
  $extension = str_replace('jpg', 'jpeg', $extension);
  $close_func = 'image'. $extension;
  if (!function_exists($close_func)) {
    return false;
  }
  
  // PATCH --------------------------------------------
  // Using the touch function prevent the GD problem if
  // safe_mode is enable under PHP 4.4.1+
  touch($destination);
  // ---------------------------------------------------
  
  return $close_func($res, $destination);
}
havran’s picture

I see. Later I need use function image_resize() and i have same problem with create thumbnail. This is much better way. Thanks.

jochenh’s picture

I am using the following setup: drupal 4.7, gd2 working fine, image module. Directory permissions are set to 777 for the following dirs: files, images, temp. Drupal file handling is set to private.

When I try to create an image i get this:

    * The selected file /tmp/tmp_bFZk7E could not be copied.
    * The selected file /home/jochenha/public_html/updates/files could not be copied.

Your image was created.

and of course nothing shows up in the gallery.

Please advise.
I even tried to run this with a 'corrected' image_gd_close function as described here: http://drupal.org/node/60155

but still no luck

Please advise
thanks!
- Jochen

jochenh’s picture

Status: Needs review » Closed (fixed)

sorry, i am closing this because it was actually a problem with my hosting. looks like they recompiled apache without GD or something...

L. Allen Poole’s picture

I'm having a similar, presumably related problem with line 284 of image.inc:

http://drupal.org/node/73986

If anyone resolves this issue, and if the solution appears relevant to 4.6, please let me know?

Thanks,
Allen