Upload error: bad image file

Okat
Okat's picture

Joined: 2009-04-05
Posts: 77
Posted: Sat, 2009-11-07 19:22

http://www.okat.nl

Didn't notice this before today, but I've been experiencing upload errors on my site. Tried uploading (different) images. I've tried several filetypes and different files and filenames (even some that were uploaded before), updated the G3 version (except for the var dir) to the latest git (gallery-gallery3-e300ede), upgraded all installed modules (gallery-gallery3-contrib-8ab32fe), ran the updater. Tried both GD2 and ImageMagick. Default and custom themes but the problem is still there.
I did not change file/dir permissions (before I tried to fix the problem) and I read threads containing upload errors. I'm positively at a loss.

PHP Version 5.2.4-2ubuntu5.7
Server API Apache 2.0 Handler
memory_limit 64M
Have no access to apache error logs
Have access to SSH

Maybe of interest:
Adding albums works, but they don't seem to be created in the 'albums' dir.
I noticed nothing being created in the temp dir

Stack trace:
#0 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/modules/gallery/helpers/graphics.php(152): gallery_error_Core::error_handler('gallery_graphic...', Array)
#1 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/modules/gallery/helpers/photo.php(126): graphics_Core::generate(Object(Item_Model))
#2 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/modules/gallery/controllers/simple_uploader.php(65): photo_Core::create(Object(Item_Model), '/home/vhosting/...', 'DSC_20081228_17...', 'DSC 20081228 17...')
#3 [internal function]: Simple_Uploader_Controller->add_photo('2')
#4 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/system/core/Kohana.php(291): ReflectionMethod->invokeArgs(Object(Simple_Uploader_Controller), Array)
#5 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/system/core/Event.php(209): Kohana::instance()
#6 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/system/core/Bootstrap.php(55): Event::run(Array)
#7 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/index.php(86): require('/home/vhosting/...')
#8 {main}

Can someone help me with this?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 22872
Posted: Sat, 2009-11-07 23:17
Quote:
dding albums works, but they don't seem to be created in the 'albums' dir.

This is a issue. See if enabling debug mode gives some clue as to why that fails.
FAQ: How do I see debug information?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
Okat
Okat's picture

Joined: 2009-04-05
Posts: 77
Posted: Sun, 2009-11-08 09:06

I guess this problem became less interesting. Today the album is added to the "albums" folder.

I did add the local.php file as well, but don't see anything special apart from the following in the log:
Seems to be an imagemagick problem where there was none before. Resize error points to ImageMagick, right?

Running ImageMagick 6.3.7 06/04/09 Q16

2009-11-08 09:59:51 +01:00 --- error: Caught exception rebuilding image: DSC 20081201 230355-1
call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: First argument is expected to be a valid callback, 'gallery_graphics::gallery_graphics::resize' was given
#0 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/modules/gallery/helpers/graphics.php(152): gallery_error_Core::error_handler('gallery_graphic...', Array)
#1 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/modules/gallery/helpers/photo.php(126): graphics_Core::generate(Object(Item_Model))
#2 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/modules/gallery/controllers/simple_uploader.php(65): photo_Core::create(Object(Item_Model), '/home/vhosting/...', 'DSC_20081201_23...', 'DSC 20081201 23...')
#3 [internal function]: Simple_Uploader_Controller->add_photo('2')
#4 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/system/core/Kohana.php(291): ReflectionMethod->invokeArgs(Object(Simple_Uploader_Controller), Array)
#5 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/system/core/Event.php(209): Kohana::instance()
#6 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/system/core/Bootstrap.php(55): Event::run(Array)
#7 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/index.php(86): require('/home/vhosting/...')
#8 {main}
2009-11-08 09:59:51 +01:00 --- alert: exception 'ErrorException' with message 'call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: First argument is expected to be a valid callback, 'gallery_graphics::gallery_graphics::resize' was given' in /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/modules/gallery/helpers/graphics.php:152
Stack trace:
#0 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/modules/gallery/helpers/graphics.php(152): gallery_error_Core::error_handler('gallery_graphic...', Array)
#1 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/modules/gallery/helpers/photo.php(126): graphics_Core::generate(Object(Item_Model))
#2 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/modules/gallery/controllers/simple_uploader.php(65): photo_Core::create(Object(Item_Model), '/home/vhosting/...', 'DSC_20081201_23...', 'DSC 20081201 23...')
#3 [internal function]: Simple_Uploader_Controller->add_photo('2')
#4 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/system/core/Kohana.php(291): ReflectionMethod->invokeArgs(Object(Simple_Uploader_Controller), Array)
#5 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/system/core/Event.php(209): Kohana::instance()
#6 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/system/core/Bootstrap.php(55): Event::run(Array)
#7 /home/vhosting/t/vhost0030521/domains/okat.nl/htdocs/www/index.php(86): require('/home/vhosting/...')
#8 {main}

 
Okat
Okat's picture

Joined: 2009-04-05
Posts: 77
Posted: Mon, 2009-11-09 09:56

By the way; I tried the rescue module as well. And replaced (all) the core files too.
Might be something left I didn't think of apart from installing (including SQL) all over, which I'd rather not do (hassle with users table and uploading all images again), unless you think this is the wisest option.

Just updated everything to latest git (gallery-gallery3-47e0d91). Problem is still there.

Remembered someting: My theme uses thumbnail sizes of 150px, changing it back still produces the same errors.

 
Okat
Okat's picture

Joined: 2009-04-05
Posts: 77
Posted: Mon, 2009-11-09 19:04

Well, did a complete new install including the database and the problem went away. Still don't know why it happened. Not what I really wanted, since I have to add all groups and users and galleries again, but it's beta after all.

 
Okat
Okat's picture

Joined: 2009-04-05
Posts: 77
Posted: Mon, 2009-11-09 19:53

Hmm, this is odd. I inserted rows from my old database into the newly created "users", "groups" and "groups_users" tables and all of a sudden I get the error again. After deleting the rows again (apart from the default users/groups) the upload works again. Am trying to reproduce.

 
Okat
Okat's picture

Joined: 2009-04-05
Posts: 77
Posted: Tue, 2009-11-10 21:52

Unless no-one is really interested, of course

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16501
Posted: Tue, 2009-11-10 22:58

o.k. I'll bite.

Quote:
I inserted rows from my old database into the newly created "users", "groups" and "groups_users" tables and all of a sudden I get the error again.

Why? There is no API developed yet for G3 to externally do stuff like this. Create the users and groups through the interface to make sure they get created properly.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
Okat
Okat's picture

Joined: 2009-04-05
Posts: 77
Posted: Tue, 2009-11-10 23:25

I know there's no API to do that. It is however a way to insert users into the gallery again. One that is bound to be used by more people than just me. Especially while G3 is still in Beta.
Anyway, I thought someone might be interested because the error someone gets isn't something someone could relate to a (broken) users or groups table. So I thought it might be of interest to
someone.
Haven't been able to totally reproduce. I inserted users this way but created groups the normal way and added the users to the groups the normal way. Everything still works.

Someone who gets the "upload error" and added users/groups the same way as me might read this and know where the problem came from.

My playground (using customized 3nids theme) http://www.okat.nl

 
BryanB

Joined: 2009-10-24
Posts: 4
Posted: Sun, 2009-11-22 01:21

Yea I'd like to know how to fix this too, I'm getting the "Upload error: bad image file" when trying to upload a .jpg through the gallery... Only server add works.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 22872
Posted: Thu, 2009-12-10 01:22

FAQ: Why do I get a Error #2038 when I try to upload more than one item
There has been some improvement and configuration added so try a recent git version and see if the above works.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
mafiouso

Joined: 2009-12-26
Posts: 4
Posted: Sat, 2009-12-26 05:04

Upload error: Bad image file
### IF YOUR GETTING THIS ERROR. READ HERE ###

it drove me crazy, it turned out to be a server config error.

from my webhost:

There was an issue with "mod_security". We have tweaked it a bit and its working fine now.

We have liberalized the rule set on the mod security file to correct the issue. The rules are set on the file '/usr/local/apache/conf/modsec_rootkits.conf'.

[Wed Oct 28 12:22:08 2009] [error] [client XXX.89.XXX.167] ModSecurity: Access denied with code 406 (phase 2). Pattern match "=(http|www|ftp)\\:/(.+)\\.(c|dat|kek|gif|jpe?g|jpeg|png|sh|txt|bmp|dat|txt|js|html?|tmp|asp)\\x20?\\?" at REQUEST_URI. [file "/usr/local/apache/conf/modsec_rootkits.conf"] [line "27"] [id "390144"] [rev "1"] [msg "Rootkit attack: Generic Attempt to install rootkit"] [severity "CRITICAL"] [hostname "YOUR URL.com"] [uri "/forum/images/avatars/gallery/pictureview-password-2008.html//appserv/main.php"] [unique_id "HIDDEN"]

HOPE THIS HELPED

 
bownes

Joined: 2010-01-26
Posts: 7
Posted: Tue, 2010-01-26 05:25

I wish that were it. I don't have mod_security...

Sever add doesn't work either.

 
Nielsie

Joined: 2010-01-20
Posts: 1
Posted: Tue, 2010-01-26 16:55

Hi All,

by the way; this mod_security thing is not working for me either....

I have been playing around with this error: bad image file for some time and it drives me mad too.
I have changed my php.ini file to a high value (10MB)
I have been digging around in apache and linux but no result.
and still it didn't work. I reduced my photo's in photoshop to lower than 1 MB, and was surprised that that didn't even seem to work either.

Now i have discovered that the image dimensions are a part of the error that i get: 'bad image file'.
When i lower the image dimensions to like 500 width, i can upload without any error.
Still, the main question remains: Why can't we upload photo's from a digital camera with dimensions like 3780 x something.....

Anyone got some ideas ?

Nielsie

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16501
Posted: Tue, 2010-01-26 17:04

FAQ: Why can't I upload big files (over a megabyte or two)?
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here