Imagecache stopped working for me on one of my sites - not sure why.

When uploading an image, the image gets put OK in this folder:

/public_html/files/photos (permissions 775) ...as 'original-image-name.jpg' (Note I have CCK type called 'photo' with an Imagefield)

and also into this folder:

/public_html/files/upload_tmp (permissions 777) ('upload_tmp' folder defined in 'admin/settings/file-system') ...as 'Display_Primaryoriginal-image-name.jpg' (where 'Display Primary' is one of my presets) - but note the image size has not been resized to the preset at that point.

But the images don't get resized and moved into this folder:

/public_html/files/imagecache/Display_Primary/files/photos (permissions 755) ...which is where they should end up.

(I put the permissions for each folder in case that makes a difference - note I cannot reset those via my FTP client - says I don't have permission to do that. I would have thought they all need to be 777, but I don't know much about how Drupal works with folder permissions.)

But the really strange thing is that for images I uploaded previously, it is working - I flush the present images and they get recreated fine in '/public_html/files/imagecache/Display_Primary/files/photos' for the older images but not for new ones.

The original image file sizes are about the same for new and old: a typical new image size: 300KB - not very large.

Thoughts? Appreciate any help.

Drupal 5.3, Imagecache 5.x-1.x-dev 2007-12-18, Imagefield 5.x-1.x-dev 2007-01-25

Comments

rick hood’s picture

Update:

I tried re-uploading one of the old images (one of the ones that was working OK - re-creating new Imagecache files after I flushed the preset settings). That images was 596 KB, 1632 x 916 pixels. It uploaded fine and created the Imagecache images fine.

I also tried resizing one of the images that was not working at all:

296KB, 1600x1200 -----> 192KB, 1200x900

and then it worked.

All images are RGB for sure and I created them the same way (Photoshop, save for web).

I don't get why this woudl work: 596 KB, 1632 x 916 ...but this would not: 296KB, 1600x1200

Anyhow, maybe this gives some clue as to what is going on?

rick hood’s picture

Category: bug » support

I have experimented more by taking an image that works, then gradually increasing its size until it doesn't work.

I took the 1632 x 916 image mentioned above and increased it until it got to 1755 x 985, which still worked ("worked" = Imagecache sizes were created OK).

But at 1760 x 988 (and higher) it did not work.

I am not getting any kind of memory error messages when it does not work.

Does this sound like I am doing something wrong with Imagecache, or should I talk to my web host?

Note it used to work, so that's why I hesitate to think its the web host, although they could have changed something.

Really appreciate any help, thanks.

---

More update:

I tried this on another site I have on this hosting plan (Drupal 5.2 and Imagecache 5.x-1.1) and I don't have the problem. I guess that indicates that it is not a problem with the server (e.g. memory) - although note that I have more modules enabled on the site I am having trouble on, if that matters.

mcvecka’s picture

I've seen the same behaviour on my locally installed Apache. According to te error log (/var/log/httpd/error_log) it seems that the problem is caused by the limited memory size allowed for one script:

[Sat Jan 26 16:56:50 2008] [error] [client 127.0.0.1] PHP Fatal error:  Allowed memory size of 16777216 bytes exhausted (tried to allocate 8192 bytes) in /var/www/html/example/includes/image.inc on line 308, referer: http://localhost/example/

An entry like this appears in the log each time I try to upload a big image.

It is possible to increase the memory limit in your php.ini file (memory_limit). Another solution would be to limit the maximum resolution of the uploadable image.

rick hood’s picture

Yes, but in my last comment above I noted that other sites on this same hosting plan (e.g. same server, same setup) are working OK. I am pretty sure these sites share the same php.ini file, so I concluded that memory limit in php.ini is not the issue. However, I will check again with my web host - will post what I find.

In the meantime, telling users to limit image size is what I am doing.

doka’s picture

Same error for me: two drupal install at one host: the D5 producing this error for large picture dimensions, D6 works fine. The PHP memory limits, versions are the same.

But I do not have imagecache in any install. I use node_image with D5, img_filter for D6.

gaele’s picture

It is possible to increase the memory limit in your php.ini file (memory_limit)

This only works if your host configuration allows that.

bbarbash’s picture

I'm having the same problem, however there are no errors in my apache error.log other than 404's indicating that the files that should have been copied by imagecache are missing. I'm using imagecache in coordination with lightbox2 to create an image gallery. Imagecache is configured with 2 presets - thumbnail and display.

I've experimented with a variety of image sizes, all the way down to 320 x 240 with a file size of less than 100KB with no luck. Out of 5 uploaded files, imagecache usually copies the first 2 as thumbnails, then maybe one of those makes it to the display stage.

I'm running on Ubuntu 2.6.22-14-server on a home machine, with apache2 as the web server and php5. PHP5 was configured to allow scripts to use 128MB of memory, and I've upped that to 256MB as a test. Still no luck. I've also tried this on Firefox 2 and IE 7 to see if maybe it was an issue with the browser. Still nothing. Any ideas?

Thanks in advance for the help.

-Brian

bbarbash’s picture

In case folks are still having trouble, I was able to get my issue solved. For me at least, it had to do with the rewrite rules that are in the Apache configuration file (or .htaccess depending on how you're configured). Take a look at the following discussion thread:

http://drupal.org/node/89841

Follow the instructions for how the rewrite rules should look, specifically the RewriteCond lines, and see if that helps. Worked for me.

-Brian

rick hood’s picture

I am still having this problem. And now problem is on a different server where I can do what I want with php.ini, jacking memory up as high as 512 and max execution time, etc... nothing works.

The original image is uploaded to /files no problem but the Imagecache versions are not created for the larger files.

Using: Imagecache 5.x-1.3 and Imagefield 5.x-1.2-rc1

I have done all mentioned above except for .htaccess stuff, which I really don't think is the answer - clean URL's are working fine and anyhow smaller images are working fine.

Weird... any ideas more would be appreciated.

rick hood’s picture

Update and more weirdness:

An image that was not working ("not working" = uploading into files folder OK, but Imagecache versions not created) was named this: press-photos-38-ext-1.jpg

I changed the name to this: press-photos-38-ext-1-again.jpg and it worked!

Is there a reason why Imagecache and/or Imagefield would not like numbers at the end of the filename?

Doesn't make sense - something else must be going on.

Shai’s picture

The following solution doesn't explain the intermittent problems. But maybe it is the problem.

It is essential that your tmp directory is set up correctly. In your site admin, go to:

http://example.com/admin/settings/file-system

to make sure you have a tmp directory set up. Imagecache needs that to correctly create the derivative.

I had many of the same symptoms as you. I finally arrived at checking on the file system settings and, voila, -- that was the problem. The tmp directory that was listed in the file system settings was a path to a directory on my Mac, where I had originally created the web site. When I exported the db and uploaded it to my server I had no clue that I had a file system setting for the tmp directory set to a path on my Mac.

Hope that is all it is for you.

Shai

JezV’s picture

Similar problem here. Imagecache worked fine on my local machine but not on the live server. Like many people, my development machine is windows and the web server is linux. So, the path to the tmp folder (defined in admin/settings/file-system) had to be changed from files\tmp to files/tmp. Simple problem, took a while for the penny to drop. Hope this helps someone.

Jez

dopry’s picture

Status: Active » Closed (fixed)

Please look in your error logs and provide any relevant information there.. watchdog and apache error logs... and open a new issue if your issue hasn't been solved in this thread.

jessicakoh’s picture

Check the .htaccess file located inside of your files/ directory. Mine now looks like:

SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
#Options None
Options FollowSymlinks

# RewriteEngine off

http://www.ubercart.org/forum/support/2451/imagecache_imagfield_imageapi...

charitygrace’s picture

my client was having the issue of the imagecache not working. turns out she was using & in the name of her image files. took out the & and imagecache worked.

tonyhrx’s picture

Some hosting companies are changing their security policies and are removing the Options +FollowSymLinks in .htaccess and changing it to Options +SymLinksIfOwnerMatch

When you visit the file system and create your file paths, Drupal puts an .htaccess docuemnt in the temp file path directory and the main filepath directory. Trouble is they have the Options +FollowSymLinks enabled.

If you change that to +SymLinksIfOwnerMatch imagecache and imagefield preview all begin to magically work. At least they did for me.