Can't get exif_imagetype working...

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
Incogito
-


Joined: 27 Jun 2006
Posts: 4

PostPosted: Tue Jun 27, 2006 9:45 am    Post subject: Can't get exif_imagetype working... Reply with quote

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 View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Tue Jun 27, 2006 10:07 am    Post subject: Reply with quote

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 View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
Incogito
-


Joined: 27 Jun 2006
Posts: 4

PostPosted: Tue Jun 27, 2006 10:10 am    Post subject: Reply with quote

: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 View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Tue Jun 27, 2006 10:32 am    Post subject: Reply with quote

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 View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
Incogito
-


Joined: 27 Jun 2006
Posts: 4

PostPosted: Tue Jun 27, 2006 11:47 am    Post subject: Reply with quote

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 View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Tue Jun 27, 2006 11:14 pm    Post subject: Reply with quote

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 View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
Incogito
-


Joined: 27 Jun 2006
Posts: 4

PostPosted: Wed Jun 28, 2006 6:56 am    Post subject: Reply with quote

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 View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group