class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
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.
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.
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.
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!
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?
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!
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!
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!
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!
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!
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:
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,
Michael
Note that I don't support the class on Windows servers.
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,
Michael
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\"
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,
Michael
Also check out this thread
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.
Do you want me to send you my broken png?
Yes, please, send me the corrupted file, I'll have a look at it.
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.
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.
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.0
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.
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).
please help
gd.jpeg_ignore_warning = 1
Mine was set to 0 before I changed it.
How about php4 ?