Hi,

Image uploads are not showing - I tested creating a new content type and added an image field.

Image field was set to use the thumbnail style and large style when viewing in teaser and full page mode.

I checked the files directory and the files were there - however when you go to the styles directory and look into the thumbnail and large directories, there are no images.

I tested loading the images on a separate page and I got the "Error generating image." message

CommentFileSizeAuthor
#12 jpg-image-uploads-788102.patch790 bytesAaronBauman
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

h3000’s picture

Also, I might add that on a drupal 6 site on the same server, images uploads are working fine.

The Drupal 7 status reports don't show any problems with the file permissions settings for the directories.

Are there any other properties or configurations to set to allow image file uploads or to make the images appear in Drupal 7?

eojthebrave’s picture

Does your watchdog table have any relevant error messages? Same goes for php/apache logs.

h3000’s picture

Just error messages whenever it tries to load the images:

image load failed directory: public://styles/gallery_thumbnail, public://IMG_3150.jpg

Unable to generate the derived image located at public://styles/gallery_thumbnail/IMG_3150.jpg.

gallery_thumbnail is a new image preset I created. But using the default thumbnail and large presets did not work as well.

hyperart’s picture

It appears that it flakes out when you add an image in a node that does not require resizing at posting.

Like, if my "medium" resolution is set to 400x400px, and I upload a 350x350px image, the <img> tag will not issue the right path, even though the image IS uploaded. However, there is no copy of the image in the "medium" folder.

If the uploads are larger than the resolution limits, then all seem to work fine.

At least that's how it seems for me!

h3000’s picture

Yes - this seems to be the case - I have been uploading image sizes within my maximum image size setting.

I now tested uploading images over the maximum image size and as mentioned by hyperart, the images appeared. Probably the process to resize the image to the preset styles was not called when the correct sized image is uploaded?

My other issue is that my image field is a multi-value image field - however, whenever I want to add a new image, I need to press the upload button and then wait for it to finish uploading before I can add a new image! This seems to be counter intuitive. Of course this is still an alpha version but I hope this will be fixed by the beta version.

acouch’s picture

Version: 7.0-alpha4 » 7.x-dev

I just experienced this problem as well with the latest dev version described in #3.

I've found that the same images will have different behavior if they have been opened with an image editor (gimp and f-spot) and resaved. The exif data from the saved images is identical except for " Unknown tag, Tagnum 0x4746 = data ===> 0" in the one that doesn't work.

I'm using PHP 5.2.6-3ubuntu4.5 with Suhosin-Patch 0.9.6.2 on ubuntu 9.04.

eojthebrave’s picture

@aaroncouch, any chance you could provide a copy of the "corrupted" image file? So I can test this out. Thanks.

acouch’s picture

here is an example "corrupted" image: http://aaroncouch.info/sites/default/files/149_0184.JPG

MrRoxy’s picture

same problem! 1 of 3 images works.

(also image cache not works...)

AaronBauman’s picture

Priority: Normal » Critical

I am only experiencing this issue with .jpg's, which others have experienced as well.
@see #821962: JPG images won't upload - GIF and PNG work fine.
Is anyone on this thread able to duplicate the issue with .gif or .png?

I confirmed the experience in #4 that this is only relevant when the image is within the limits.

Bumping to critical, since by default there is no resolution limit, hence by default .jpg uploads are broken for image field.

AaronBauman’s picture

Title: Image uploads are not showing » jpg images do not display for image fields, jpg derivitaves not created

updating title to more precisely reflect the issue

AaronBauman’s picture

FileSize
790 bytes

The attached patch fixes the issue for me, but I have no idea why:

--- modules/system/image.gd.inc	30 Jan 2010 07:59:25 -0000	1.15
+++ modules/system/image.gd.inc	8 Jul 2010 15:13:50 -0000
@@ -336,8 +336,8 @@ function image_gd_create_tmp(stdClass $i
  */
 function image_gd_get_info(stdClass $image) {
   $details = FALSE;
-  $data = getimagesize($image->source);
-
+  $dummy = array();
+  $data = getimagesize($image->source, $dummy);
   if (isset($data) && is_array($data)) {
     $extensions = array('1' => 'gif', '2' => 'jpg', '3' => 'png');
     $extension = array_key_exists($data[2], $extensions) ?  $extensions[$data[2]] : '';

For some reason, throwing the second optional parameter to getimagesize causes the return value to be properly populated.
I can't find a reasonable explanation after cursory searching and I don't care to offer my own conjecture.

Is this just a quirk on my PHP install?
Can anyone confirm?

chx’s picture

I downloaded http://aaroncouch.info/sites/default/files/149_0184.JPG and ran php -r 'var_dump(getimagesize("149_0184.JPG"));' and got the expected results. I tried PHP 5.2.13 and PHP 5.3.2


array(7) {
  [0]=>
  int(3664)
  [1]=>
  int(2748)
  [2]=>
  int(2)
  [3]=>
  string(26) "width="3664" height="2748""
  ["bits"]=>
  int(8)
  ["channels"]=>
  int(3)
  ["mime"]=>
  string(10) "image/jpeg"
}

can you tell me what's the problem, here?

AaronBauman’s picture

Status: Active » Needs review
AaronBauman’s picture

I am running php 5.2.9, and I get the same behavior chx described on the command line, but not in Drupal.

To reproduce in Drupal:
- install minimal from latest dev
- enable image + fields ui
- create a node type and add an image field to it
- create a node of that type and upload the referenced image

here is my debugging code:

--- modules/system/image.gd.inc	30 Jan 2010 07:59:25 -0000	1.15
+++ modules/system/image.gd.inc	8 Jul 2010 15:52:41 -0000
@@ -336,7 +336,9 @@ function image_gd_create_tmp(stdClass $i
  */
 function image_gd_get_info(stdClass $image) {
   $details = FALSE;
+debug($image, NULL, TRUE);
   $data = getimagesize($image->source);
+debug($data, NULL, TRUE);
 
   if (isset($data) && is_array($data)) {
     $extensions = array('1' => 'gif', '2' => 'jpg', '3' => 'png');

The result of the debugging code, when following the steps to reproduce above (load the page at least twice to see it).
Note that $data is empty:

Debug: stdClass Object ( [source] => public://149_0184.JPG [toolkit] => gd ) in image_gd_get_info() (line 339 of /Users/bauman/Sites/contributions/drupal-HEAD/modules/system/image.gd.inc).
Debug: in image_gd_get_info() (line 341 of /Users/bauman/Sites/contributions/drupal-HEAD/modules/system/image.gd.inc).

Also worth noting, the filename passed to getimagesize() is prefixed with the schema (defaults to "public://"), which maybe changes things a bit.

asimmonds’s picture

I didn't see this issue when I opened #844676: (Tests needed) Stream wrappers stream_seek() return is invalid which I think could be related, fseek() used on a Drupal stream doesn't work properly. You can see this when getimagesize() tries to process a .jpg with EXIF metadata.

chx’s picture

Status: Needs review » Closed (duplicate)

Excellent analysis closing this one down in favor of the other, already patched issue.

netpumber’s picture

Guyz im trying to run the patch at #12 but doesn't seems to work
it returns me this :

Patching file image.gd.inc using Plan A...
Hunk #1 failed at 336.
1 out of 1 hunks failed--saving rejects to image.gd.inc.rej
done

That wahts i run
patch image.gd.inc < jpg-image-uploads-788102.patch

Any idea on how to fix this issue?

chriscalip’s picture

Status: Closed (duplicate) » Active

Error Spotted @ Drupal 7.12
Drupal 7.12 already contains patch http://drupal.org/files/issues/php_is_a_sorry_mess.patch provided by issue
#844676: (Tests needed) Stream wrappers stream_seek() return is invalid @link http://drupal.org/node/844676

Because 7.12 has the patch recommended by the said issue and error still occurs; I am changing to active. Please update as needed.

** Edit **

I would also like to state that comment # 12 patch http://drupal.org/files/issues/jpg-image-uploads-788102.patch fixed the error sighting on my install.

tim.plunkett’s picture

This issue has been marked as a duplicate of #844676: (Tests needed) Stream wrappers stream_seek() return is invalid. If there is still a problem, please follow up over there.

JvE’s picture

Issue summary: View changes
Priority: Critical » Major
Status: Active » Closed (duplicate)
Hemu45043’s picture

Failed to load thumbnail msg received in my mobile oppo F1S
Please solve my problem