View previous topic :: View next topic |
Author |
Message |
Incogito -
Joined: 27 Jun 2006 Posts: 4
|
Posted: Tue Jun 27, 2006 9:45 am Post subject: Can't get exif_imagetype working... |
|
|
Well, I've been working on an image gallery script, and have been very succesfull so far, except that the exif_imagetype function that I need to determine if the file read is an image, doesn't seem to exist.
I've enabled both exif, and mbstring DLL's, and have added the following to my arguments line for PHP in Abyss:
Code: | --enable-exif --enable-mbstring |
Here's the function using exif_imagetype:
Code: | //For grabbing all images in a folder
function grab_images($folder)
{
$folder = rtrim($folder, "/");
$folder = rtrim($folder, "\\");
$tmp_files = read_dir($folder);
$returnData = array();
$index = 1;
while($index<count($tmp_files))
{
$file = $folder . '/' . $tmp_files[$index];
if(!is_dir($folder . $tmp_files[$index]))
{
if(exif_imagetype($file) !== FALSE)
{
$returnData[] = $tmp_files[$index];
}
}
++$index;
}
return($returnData);
} |
I also figured I could use mime_content_type, along with strpbrk, to determine if it's an image, but then I get an error reporting lack of file permissions :?
Any help would be appreciated. |
|
Back to top |
|
|
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Tue Jun 27, 2006 10:07 am Post subject: |
|
|
php.net wrote: | Windows users must enable both the php_mbstring.dll and php_exif.dll DLL's in php.ini. The php_mbstring.dll DLL must be loaded before the php_exif.dll DLL so adjust your php.ini accordingly. |
--enable-exif and --enable-mbstring are paramaters for the configure script when compiling PHP yourself.
As to your problem, "an error reporting lack of permissions" isn't very helpful. Make use of your clipboard. _________________
|
|
Back to top |
|
|
Incogito -
Joined: 27 Jun 2006 Posts: 4
|
Posted: Tue Jun 27, 2006 10:10 am Post subject: |
|
|
:P Indeed, I wondered why I couldn't find anything in the manual.
Thanks for the pointer.
However, I still get a exif_imagetype undefined error - and, yes, mbstring is loaded before exif ;)
[edit]
Missed that last bit of your post.
But, if you really must see the actual error for mime_content_type(though I'ld prefer to use exif_imagetype, which just says it's undefined), here you go:
Code: |
Warning: mime_content_type(/Windows/php.ini) [function.mime-content-type]: failed to open stream: Permission denied in C:\www\include.inc on line 55
|
That's using a modified version of the function above, and on line 55:
Code: | $mimetype_of_file = mime_content_type($file); |
When I use exif_imagetype, all I get is "the function exif_imagetype is undefined" (or something similar), which is fairly straight forward. |
|
Back to top |
|
|
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Tue Jun 27, 2006 10:32 am Post subject: |
|
|
Create a blank PHP script, and paste:
Code: | <?php
error_reporting(E_ALL);
var_dump(dl("php_exif.dll"));
?> |
Does that produce a warning? Can you paste it?
Also, you get permission denied with mime_content_type because it's loading a file it doesn't have access to. (Who would've thought.) _________________
|
|
Back to top |
|
|
Incogito -
Joined: 27 Jun 2006 Posts: 4
|
Posted: Tue Jun 27, 2006 11:47 am Post subject: |
|
|
Well, obviously - that's why I didn't bother pasting the error in the first place, and why I tried exif_imagetype.. :wink:
But, here are the results from the code you suggested above:
bool(true)
..and that's it. confuses me a little, but, hey, what can you expect from somone who has only been using PHP for a month.. :P
Thanks for your help so far. |
|
Back to top |
|
|
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Tue Jun 27, 2006 11:14 pm Post subject: |
|
|
Incogito wrote: | Well, obviously - that's why I didn't bother pasting the error in the first place, and why I tried exif_imagetype.. :wink:
But, here are the results from the code you suggested above:
bool(true)
..and that's it. confuses me a little, but, hey, what can you expect from somone who has only been using PHP for a month.. :P
Thanks for your help so far. |
I was under the impression that it was a question.
Anyhow, that means it loaded the dll sucessfully.
Try:
Code: | <?php
dl("php_exif.dll");
var_dump(function_exists("exif_imagetype"));
?> |
If it's true then the dll just isn't getting loaded by php automatically, if false then you most likely have the wrong dll or something. _________________
|
|
Back to top |
|
|
Incogito -
Joined: 27 Jun 2006 Posts: 4
|
Posted: Wed Jun 28, 2006 6:56 am Post subject: |
|
|
Returns True.
Anyway, I'll fiddle around with my PHP.ini a little more, and see how it goes. Thanks for your help. |
|
Back to top |
|
|
|