I am using image module (v 1.146.2.14 2006/02/23)

When I upload an image (using image assist v 1.43.2.12 2005/10/25), the process works fine, and the image is stored correctly in the directory structure. But when I insert them into a page, the images show up as broken links(IE), or I just see the image description text(Firefox).

If I right click on one of the broken links and click properties to see the url, it shows like "http://www.yaq.lan/yaq/system/files?file=images/Chico_interrogacion.thum...".

If I right click and then select view image, I get the following message:

The image “http://www.yaq.lan/yaq/system/files?file=images/C%C3%B3mo%20elegir%20Uni...” cannot be displayed, because it contains errors.

The image file however does not appear to be corrupted, because I can open it directly with an image viewer.

In admin/settings, the File system path is /var/www/drupal_downloads. Double checked that drupal_downloads is writeable by drupal (there are no error alerts at the top of the admin/settings page such as when this directory is un readable), even tried chmod 777 to no avail.

Download method is set to private. According to my admin>settings page... "The built-in GD2 toolkit is installed and working properly."

I am using:
Fedora Core 4
PHP 4.3.11
Apache 2.0.54
Mysql 4.1.16

Any suggestions as to what could be the problem, or where to look for clues?

Thanks,

Steve

Files: 
CommentFileSizeAuthor
#13 Response headers1.8 KBsja1
#10 image_problem.tar.gz2.51 KBsja1

Comments

naquah’s picture

Title:Images upload but don't display - see only text» Images upload but don't display because they are corrupted
Assigned:Unassigned» naquah
Category:bug» support
Priority:Critical» Normal

If your images are corrupted, that usually means that PHP gives some error or warning, thus adding text to the image that the browser doesn't understand.

You should try the following: do exactly as you said and click 'view image', then if you see the 'cannot be displayed, because it contains errors' message, try to save the image. (File > Save Page As, or similar.) Then open the saved file in a text editor and take a look at what's inside. (And post any relevant stuff here.)

sja1’s picture

Title:Images upload but don't display because they are corrupted» PHP error doesn't seem to be the culprit

Hi, thanks for your help.

I checked my php.ini, and the error logging is set to E_ALL.

However, no errors are being generated in the log, just a warning from a module I have written that has nothing to do with images:
"Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in /var/www/html/yaq/modules/centro_edu/centro_edu.module on line 27"

I have done as you suggested and tried to save the image. It appears to do the save, but when I look in the directory I have saved to the file is not there. If I look in the download manager at the entry for the download just attempted, and click on "open", I get the message "File does not exist. It may have been renamed, moved, or deleted since it was downloaded".

Perhaps if I knew if it is Drupal or another program that generates the "The image “http://www.yaq.lan/yaq/system/files?file=images/Chico_interrogacion.thum...” cannot be displayed, because it contains errors." message, that might help me to look for clues? I checked the Drupal error log, but no events are created upon loading the page, nor on trying to view or download the image.

naquah’s picture

Title:PHP error doesn't seem to be the culprit» Images upload but don't display because they are corrupted

You should try saving the image using your browser, not with a download manager. In Firefox click view image in the context menu, then save the image using File > Save Page As.

The error message is given by Firefox, because it cannot render the image if it is corrupted.

Please note that when replying to an issue the Title field changes the title of the whole issue. Only change it if you have a more descriptive title than the current one.

sja1’s picture

Hello again,

Here's what I did:

1) Right click on the text (caption) that shows up where the image should be, and choose "Save image as" from the context menu (save page doesn't seem to show up as an option).
2) A "save image" dialog appears, allowing me to choose a name for the file (I write in "test.jpg") and a directory to save it to. I click the "save" button on this dialog.
3) A "downloads" dialog appears, with a list of all my recent downloads. "test.jpg" appears as "done". To the right of "test.jpg" appear two links: "open" and "remove".
4) I click on "open", and get the message: "test.jpg does not exist. It may have been renamed, moved or deleted since it was downloaded.

It seems as though drupal isn't returning a file at all, but it's strange as no error messages (that I can find) have been generated.

Are there any other tests I might try that could shed some light on what's going wrong?

Thanks again for your help.

Steve

praseodym’s picture

So if you can download the file and open it with an image editor/viewer, can you also that same file in Firefox (without re-downloading it). That helps us check if it is a Firefox problem or a problem with Firefox downloading the file, or maybe something else.

sja1’s picture

If I put this URL into firefox: file:///var/www/drupal_downloads/images/Chico_interrogacion.thumbnail.jpg

It displays the picture in the browser window with no problem. It wouldn't appear to be a firefox problem.

My gut feeling is that it's some environmental (apache or php) or drupal configuration problem that prevents the Drupal file system from retrieving files from the download directory. If I could only find an error message somewhere...

naquah’s picture

What about if you upload a text file as an attachment (using the upload module), then try to download it and see what's in it.

sja1’s picture

Text files are working. I created a simple text file and uploaded it to a page node. Then navigated to the page, clicked on the download and it downloaded perfectly to my desktop. I could open the downloaded file without problem.

praseodym’s picture

Could you check the headers that are sent to your browser? Easiest is probably using curl -I [url].

sja1’s picture

StatusFileSize
new2.51 KB

Well, the results are interesting. By the way, thanks to you guys for taking time to help me with this.

I must admit I had never heard of curl, as I'm a little new to all this, but I think I have what you asked for. I tried 2 commands, which I'll repeat here so you can see exactly what I typed:

1: curl -i http://www.yaq.lan/yaq/system/files?file=images/Chico_interrogacion.thum... > yaqhead.txt
2: curl http://www.yaq.lan/yaq/system/files?file=images/Chico_interrogacion.thum... > yaq.jpg

I don't know enough to interpret the header, but the interesting thing is that the yaq.jpg seems to be my image file. I can open it with gimp, and also with the gThumb Image Viewer. That just makes my problem seem all the weirder.

The header file I was only able to inspect doing "more yaqhead.txt". Gedit wouldn't work on it.

I've attached both files so you can take a look.

naquah’s picture

This takes us a bit further. The headers seem alright, so that's not the problem, I think. When the file is downloaded with curl, the image is alright as well.

My guess is that it is a gzip (compressio) problem... praseodym?

praseodym’s picture

Try installing the Web Developer Toolbar in Firefox and use Information > Response Headers to get a copy of the headers and paste them here. That way we can see if Firefox gets gzipped content.

sja1’s picture

StatusFileSize
new1.8 KB

Very strange and interesting....

I installed the toolbar, and looked at the header as praseodym suggested (text file attached), and I did see that the gzip type was in use. This reminded me that I had enabled the ob_gzhandler at one point in the php.ini. So I disabled it, and... that didn't solve the problem. However, all of a sudden, I started getting errors in the error log.

Type php
Date Thursday, April 6, 2006 - 17:10
User arrigenna
Location /yaq/admin/modules
Message Cannot modify header information - headers already sent by (output started at /var/www/html/yaq/modules/centro_edu/centro_edu.module:275) in /var/www/html/yaq/includes/common.inc on line 192.
Severity error
Hostname 192.168.1.51

Before I had only been getting warnings, but not in the watchdog, only in the php error log:

[client 192.168.1.11] PHP Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in /var/www/html/yaq/modules/centro_edu/centro_edu.module on line 275
[client 192.168.1.11] PHP Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in /var/www/html/yaq/modules/centro_edu/centro_edu.module on line 287

I had thought that the warnings about deprecated syntax only meant I should be aware that the code might not work for future versions of PHP, but for the time being wouldn't give any problems. So it didn't occur to me that this could be related to the image problem. After turning off the ob_gzhandler, the warnings turned into errors, and still related to the same module: centro_edu.module (one of my first attempts at writing a module). I turned off the module, and the images now display properly. I must admit, I don't know what the interaction was that caused the problem.

So I guess my next step is to rewrite my module to eliminate the deprecated syntax.

Thanks very much for all your help!

naquah’s picture

Status:Active» Fixed

Glad we could help!

praseodym’s picture

FYI, the 'headers already sent' is probably caused by PHP printing an error before the headers are set. This will corrupt the image. Solving the deprecated code would help (it says deprecated, not depreciated which means that it'll not work in next versions like you thought).

Anonymous’s picture

Status:Fixed» Closed (fixed)