Error in creating JPEG image from source.

See all posts Reply

Error in creating JPEG image from source. new!
by Michael, 13 years, 7 months ago
Hi,
This is really puzzling.
We've scanned some documents onto our server, and we're using the upload class to resize/rename/relocate the images.
Our server is running XAMPP, on Windows XP. (Therefore I've ruled out CHMOD, was I right to?)

This has been absolutely fine for the past month or so, but we've moved the server and we're getting the following error message;
Error in creating JPEG image from source.

I can't find any mention of where this error originates, or what it means. It's returning false on the $upload->processed() call.

Any information that you could give me would be great. Just an idea of where to start.

Regards,
MichaelReply
Re: Error in creating JPEG image from source. new!
by colin, 13 years, 7 months ago
The log produced by the class will probably tell you more about the error. Are you sure GD is installed on the server?

Note that I don't support the class on Windows servers.Reply
Re: Error in creating JPEG image from source. new!
by Michael, 13 years, 7 months ago
Hi,

Thanks for your response.

Everything was working fine for thousands of files a week ago, we just physically moved the computer it was running on. So I am certain that anything that needs to be installed is still installed.
The images are still in jpg format too, but they may be from a different source (a different scanner).

I was not aware that the script was unsupported in Windows, if you are unable to help, I understand, and I appreciate your response.

The end of the log is posted below, the only thing that strikes me as unusual is the folder "docs/\" which I had as set to "docs/" (I assume it's a Windows thing). However this was definitely working, as-is, very recently.

It does confirm that "- MIME validated as image/jpeg", and;
- class version : 0.29
- operating system : WINNT
- PHP version : 5.3.5
- GD version : 2.0.34

source is a local file files/10001303827667DOC019.jpg
- local file name OK

source variables
- You can use all these before calling process()
file_src_name : 10001303827667DOC019.jpg
file_src_name_body : 10001303827667DOC019
file_src_name_ext : jpg
file_src_pathname : files/10001303827667DOC019.jpg
file_src_mime : image/jpeg
file_src_size : 363379 (max= 134217728)
file_src_error : 0

process file to docs/\
- file size OK
- file mime OK : image/jpeg
- new file name ext : jpeg
- new file name body : Other.1303833501
- destination variables
file_dst_path : docs/\
file_dst_name_body : Other.1303833501
file_dst_name_ext : jpeg
- image operation, change extension for conversion type
- checking for auto_rename
- destination file details
file_dst_name : Other.1303833501.jpeg
file_dst_pathname : docs/\Other.1303833501.jpeg
- Other.1303833501.jpeg doesn't exist already
- image resizing or conversion wanted
- error: Error in creating JPEG image from source.

Regards,
MichaelReply
Re: Error in creating JPEG image from source. new!
by colin, 13 years, 7 months ago
When I say I don't support the class on Windows, I mean I cannot guarantee that it will work properly on Windows.

You should use the last version (0.31), this may solve your problem.

The rest all looks fine. Maybe you can call process() with "docs" rather than "docs/" or "docs\"Reply
Re: Error in creating JPEG image from source. new!
by Michael, 13 years, 7 months ago
I've tried updating to 0.31, and I've tried a number of combinations (docs, docs/, docs\ etc.) and still nothing.
I've just tried swapping out the images for other jpg files, and that worked absolutely fine.

This is most puzzling, I guess it's something to do with the images we're trying to work with.
Is it possibly something regarding jpeg extensions as opposed to jpg? I can't see why that would be the case though.

Thanks for your help!

Regards,
MichaelReply
Re: Error in creating JPEG image from source. new!
by colin, 13 years, 7 months ago
Can you send me one of these JPEGS?

Also check out this threadReply
Re: Error in creating JPEG image from source. new!
by Michael, 13 years, 7 months ago
The problem was solved by batch converting them all to jpg in ifran viewer, even though they were already jpg files to begin with.

The files in question are quite sensitive, however I'll see if there any that I could send, to potentially avoid the situation in the future.Reply
Re: Error in creating JPEG image from source. new!
by colin, 13 years, 7 months ago
So they may not be standard JPEG files... I'd be interested in having one of these files. You can send it to me by email and I'll keep it confidential.Reply
Re: Error in creating JPEG image from source. new!
by Steve, 12 years, 6 months ago
Same deal for me with a PNG file. The file is corrupt I'm sure but this brought my system to a halt. Is there a way to test a file compatibility before doing a process call? So that I can let users know the file is faulty before my system tries to resize it?

Do you want me to send you my broken png?Reply
Re: Error in creating JPEG image from source. new!
by colin, 12 years, 5 months ago
There isn't really a way to check whether the file is corrupted or not. It could be possible, but would be a quite large endeavor, and in fact will probably amount to load it with GD to check it, which is actually what seems to be causing problems anyway.

Yes, please, send me the corrupted file, I'll have a look at it.Reply
Re: Error in creating JPEG image from source. new!
by dreamer, 12 years, 5 months ago
Here is a sample:
http://ksped.nknu.edu.tw/test/sample.jpg
It created by a large-scale printer(It is a printer but it can also scan and produce a image).It's very strange when I re-save the original image,It become OK.But error message(Error:Error in creating JPEG image from source.
) will appear when uploading the original image.
Please help ,thank you everyone.Reply
Re: Error in creating JPEG image from source. new!
by colin, 12 years, 5 months ago
The file is OK. It is mode likely that you are running out of memory.Reply
Re: Error in creating JPEG image from source. new!
by dreamer, 12 years, 5 months ago
This file(http://ksped.nknu.edu.tw/test/sample.jpg) is created by Kyocera Taskalfa300i(http://www.kyoceradocumentsolutions.com.tw/products/copy/copy02/TASKalfa_300i)Reply
Re: Error in creating JPEG image from source. new!
by dreamer, 12 years, 5 months ago
Thank you , colin.
I hope my poor English hasn't bother you.
But I think that may not be the memory problem .
Because it happens everytime when the client use large-scale printer .But never happen if the client use the usual scanner.
You can try to download the image and upload it. If it fails to upload . Please open the image and re-save it(you will find out that this time the size of the image become bigger) then retry to upload again and uploading should be succeed.
Since more and more clients use this kind's printer instead of the usual scanner It really bother me .And I don't know how to solve the problem ,In fact I don't know what's wrong at all.
I guess the image is created by a special protocol ,It's not usual JPG file.Reply
Re: Error in creating JPEG image from source. new!
by colin, 12 years, 5 months ago
Well, I have tried the JPEG you sent on my test instance, and it worked. The file looks like a standard JPEG to me.

So maybe it is due to the GD version on your server. I have this on mine:
- PHP version : 5.3.10-2
- GD version : 2.0Reply
Re: Error in creating JPEG image from source. new!
by dreamer, 12 years, 5 months ago
Dear colin ,thanks a lot.

My PHP Version 5.3.8 GD Version:bundled (2.0.34 compatible)

I try to run the code:

$src = imagecreatefromjpeg("sample.jpg");

It doesn't work and returns:

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg, libjpeg: recoverable error: Corrupt JPEG data: 2478 extraneous bytes before marker 0xd9 in...

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: 'sample.jpg' is not a valid JPEG file in...

But the code works when I re-save the image(Size become 2.67M)

I am confused now.Reply
Re: Error in creating JPEG image from source. new!
by colin, 12 years, 5 months ago
It looks to me like the version of libjpeg on your system reports the file as being erroneous. GD, which uses libjpeg then discards the image as invalid.

I am not too sure how you could solve the problem, but in any case, it is a libjpeg/GD issue, and not a class issue. Try to update your system, or even downgrade libjpeg or GD (for instance, your files work on GD 2.0 on my box).Reply
Re: Error in creating JPEG image from source. new!
by Ahmet, 9 years, 10 months ago
problem !!!!

please helpReply
Re: Error in creating JPEG image from source. new!
by Kirsty, 12 years, 5 months ago
Thanks for posting this thread. I process thousands of photos a month using this wonderful class, but about 1 in 500 has this same problem: won't process and says corrupted jpeg data. Based on the discussion in this thread, I was able to find a fix that worked for me. Anyone else having the same problem should try it: add this line to your php.ini file:

gd.jpeg_ignore_warning = 1

Mine was set to 0 before I changed it.Reply
Re: Error in creating JPEG image from source. new!
by colin, 12 years, 5 months ago
Thank you for your feedback. I have added your workaround to the FAQReply
Re: Error in creating JPEG image from source. new!
by dreamer, 12 years, 5 months ago
But "gd.jpeg_ignore_warning = 1" doesn't work at php4.
How about php4 ?Reply
Re: Error in creating JPEG image from source. new!
by Kirsty, 12 years, 5 months ago
Cool, I'm sure people will find that helpful :)Reply