FUNCTION TO CHECK IMAGE
9 answers - 453 bytes -

Hi all.
I'm having a problem regarding image handling. Sometimes an image can be showed in browser normally (in my computer) but when I
upload it into my site that image is not valid, so there is an issue in my getimagesizes() function.
Is there any function to recover such problem? I used "if(file_exists($image_path))" but it couldn't solve the problem.
Input would be appreciated
Best Regards
BBC
**o<0>o**
No.1 | | 624 bytes |
| 
At 12:49 AM -0700 9/10/06, BBC wrote:
>Hi all.
>I'm having a problem regarding image handling. Sometimes an image
>can be showed in browser normally (in my computer) but when I
>upload it into my site that image is not valid, so there is an issue
>in my getimagesizes() function.
>Is there any function to recover such problem? I used
>"if(file_exists($image_path))" but it couldn't solve the problem.
>Input would be appreciated
>
How are you uploading your image?
What is reporting your image is not valid?
tedd
No.2 | | 1071 bytes |
| 
PGP SIGNED MESSAGE
Hash: SHA1
BBC wrote:
Hi all.
I'm having a problem regarding image handling. Sometimes an image can be showed in browser normally (in my computer) but when I
upload it into my site that image is not valid, so there is an issue in my getimagesizes() function.
Is there any function to recover such problem? I used "if(file_exists($image_path))" but it couldn't solve the problem.
Input would be appreciated
Best Regards
BBC
**o<0>o**
- From what it sounds like you are doing, you are uploading a file through
some form, then manipulating it's size. Is this correct? What happens
when you stop manipulating it's size and try to view just the uploaded
file?
- --
Christopher Weldon, ZCE
President & CE
Cerberus Interactive, Inc.
cweldon (AT) cerberusonline (DOT) com
979.739.5874
PGP SIGNATURE
Version: GnuPG v1.4.1 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
R0uKdIwEaPBGBc14AoZQzo4=
=epdR
PGP SIGNATURE
No.3 | | 1022 bytes |
| 
BBC wrote:
Hi all.
I'm having a problem regarding image handling. Sometimes an image can be showed in browser normally (in my computer) but when I
upload it into my site that image is not valid, so there is an issue in my getimagesizes() function.
Is there any function to recover such problem? I used "if(file_exists($image_path))" but it couldn't solve the problem.
Input would be appreciated
- From what it sounds like you are doing, you are uploading a file through
some form, then manipulating it's size. Is this correct?
Yes it is, but the uploading was going well (size is ok). When I show the image on the web using getimagesizes(), 'sometimes' such
image size couldn't be resolved.
Is there any function to define that image is ok or not?
What happens when you stop manipulating it's size and try to view just the uploaded
file?
Size of image (after or before uploading) would be same. but the issue still there (sometimes)
No.4 | | 806 bytes |
| 
At 12:49 AM -0700 9/10/06, BBC wrote:
>Hi all.
>I'm having a problem regarding image handling. Sometimes an image
>can be showed in browser normally (in my computer) but when I
>upload it into my site that image is not valid, so there is an issue
>in my getimagesizes() function.
>Is there any function to recover such problem? I used
>"if(file_exists($image_path))" but it couldn't solve the problem.
>Input would be appreciated
>
How are you uploading your image?
I upload a file through some form then I manipulate it's size
What is reporting your image is not valid?
Size of image can't be define seem's like the image is not there, but it's not happened all the time.
No.5 | | 1073 bytes |
| 
At 11:40 PM -0700 9/10/06, BBC wrote:
At 12:49 AM -0700 9/10/06, BBC wrote:
>>Hi all.
>>I'm having a problem regarding image handling. Sometimes an image
>>can be showed in browser normally (in my computer) but when I
>>upload it into my site that image is not valid, so there is an issue
>>in my getimagesizes() function.
>>Is there any function to recover such problem? I used
>>"if(file_exists($image_path))" but it couldn't solve the problem.
>>Input would be appreciated
>>
>
>How are you uploading your image?
>I upload a file through some form then I manipulate it's size
Don't manipulate it's size and see if that works.
>Size of image can't be define seem's like the image is not there,
>but it's not happened all the time.
Can't help with sporadic problems -- that's probably a logic error.
tedd
No.6 | | 1547 bytes |
| 
PGP SIGNED MESSAGE
Hash: SHA1
BBC wrote:
>BBC wrote:
Hi all.
I'm having a problem regarding image handling. Sometimes an image can be showed in browser normally (in my computer) but when I
upload it into my site that image is not valid, so there is an issue in my getimagesizes() function.
Is there any function to recover such problem? I used "if(file_exists($image_path))" but it couldn't solve the problem.
Input would be appreciated
>- From what it sounds like you are doing, you are uploading a file through
>some form, then manipulating it's size. Is this correct?
Yes it is, but the uploading was going well (size is ok). When I show the image on the web using getimagesizes(), 'sometimes' such
image size couldn't be resolved.
Is there any function to define that image is ok or not?
>What happens when you stop manipulating it's size and try to view just the uploaded
>file?
Size of image (after or before uploading) would be same. but the issue still there (sometimes)
What types of images are these? JPG, PNG, GIF?
- --
Christopher Weldon, ZCE
President & CE
Cerberus Interactive, Inc.
cweldon (AT) cerberusonline (DOT) com
979.739.5874
PGP SIGNATURE
Version: GnuPG v1.4.1 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
zfIJGqxli9pHPHrcHoi8FjI=
=sllc
PGP SIGNATURE
No.7 | | 396 bytes |
| 
What types of images are these? JPG, PNG, GIF?
Its jpg. Look I don't know exactly what your point, I'm just asking you about the function to resolve the size of image like the
codes below:
if (file_exists($img_path)){
list($width,$height) = getimagesizes($img_path);
}else{
$width = $ height = $max_size;
}
So is there any other option to replace file_exists();?
No.8 | | 2166 bytes |
| 
PGP SIGNED MESSAGE
Hash: SHA1
BBC wrote:
>What types of images are these? JPG, PNG, GIF?
Its jpg. Look I don't know exactly what your point, I'm just asking you about the function to resolve the size of image like the
codes below:
if (file_exists($img_path)){
list($width,$height) = getimagesizes($img_path);
}else{
$width = $ height = $max_size;
}
So is there any other option to replace file_exists();?
Well, if I do remember correctly, then you are uploading a file. If
that's the case, then rather than using file_exists() you should be
using is_uploaded_file. you've verified that is_uploaded_file()
returns true, then use move_uploaded_file() to move the file to
someplace on your filesystem. If that returns true, then you should not
have to check file_exists again and just be able to use get getimagesize().
So, a good function for this would probably be:
function getUploadedImageSize($image, $to_path) {
global $max_size;
$width = $height = $max_size;
if (is_uploaded_file($image)) {
if (move_uploaded_file($image, $to_path)) {
list($width,$height) = getimagesize($to_path);
}
}
return array($width, $height);
}
list($width, $height) = getUploadedImageSize($tmp, '/the/final/path');
BTW, I don't know if you did a copy and paste from your code or if you
just typed it in really quickly, but you do have a few syntactical
errors in the code above. First, the image sizing function is
getimagesize - singular, not plural. Second, in your assignment
statement, you have a space where there should not be one:
$width = $ height = $max_size;
^
Just wanted to make sure you knew about that in case it was copied and
pasted.
- --
Christopher Weldon, ZCE
President & CE
Cerberus Interactive, Inc.
cweldon (AT) cerberusonline (DOT) com
979.739.5874
PGP SIGNATURE
Version: GnuPG v1.4.1 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
YRxq4EhHkeJpspLW0RdU=
=Kxek
PGP SIGNATURE
No.9 | | 2557 bytes |
| 
BBC wrote:
What types of images are these? JPG, PNG, GIF?
>Its jpg. Look I don't know exactly what your point,
>>I'm just asking you about the function to resolve the
>>size of image like the
>codes below:
>if (file_exists($img_path)){
>list($width,$height) = getimagesizes($img_path);
>}else{
>$width = $ height = $max_size;
>}
>So is there any other option to replace file_exists();?
>
Well, if I do remember correctly, then you are uploading
>a file. If
that's the case, then rather than using file_exists()
>you should be
using is_uploaded_file. you've verified that
>is_uploaded_file()
returns true, then use move_uploaded_file() to move the
>file to
someplace on your filesystem. If that returns true, then
>you should not
have to check file_exists again and just be able to use
>get getimagesize().
So, a good function for this would probably be:
function getUploadedImageSize($image, $to_path) {
global $max_size;
$width = $height = $max_size;
if (is_uploaded_file($image)) {
if (move_uploaded_file($image, $to_path)) {
list($width,$height) = getimagesize($to_path);
}
}
return array($width, $height);
}
list($width, $height) = getUploadedImageSize($tmp,
>'/the/final/path');
BTW, I don't know if you did a copy and paste from your
>code or if you
just typed it in really quickly, but you do have a few
>syntactical
errors in the code above. First, the image sizing
>function is
getimagesize - singular, not plural. Second, in your
>assignment
statement, you have a space where there should not be
>one:
$width = $ height = $max_size;
^
Just wanted to make sure you knew about that in case it
>was copied and
pasted.
thank you for your input, it really helps.
Semarakkan kemerdekaan RI ke 61 th dengan ikut bermain netkuis 17-an di
Kumpulkan poin sebanyak-banyaknya. Dan siap-siap tunggu rejeki dari sponsor kami.