Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 5th, 2006, 4:04 AM   #1
dpsleep
Newbie
 
Join Date: May 2006
Posts: 16
Rep Power: 0 dpsleep is on a distinguished road
finding image type

so i have an itunes controller i mad a long while ago, but never finished. i have it loading artwork, but the only problem is, when i have it save the image file to a temp directory, i have to make the filename and extention. the problem this gives me is the image file could be jpg bmp png anything and i wont know cause im telling it the file name. so i was wondering if there was a function in php i could use to find the image type, cause i just cant figure anything out. if you want a look at the controller, just goto http://austin.cycodude.com:81/player.php.
dpsleep is offline   Reply With Quote
Old Jun 5th, 2006, 6:37 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
See here and the comments therewith.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jun 5th, 2006, 7:28 AM   #3
dpsleep
Newbie
 
Join Date: May 2006
Posts: 16
Rep Power: 0 dpsleep is on a distinguished road
thanks a bunch, ive been searching php.net for a while but i never found that.
edit: ok i have no clue how this works, totaly undocumented exept comments that say nothing but how to do that without that function.

Last edited by dpsleep; Jun 5th, 2006 at 7:47 AM.
dpsleep is offline   Reply With Quote
Old Jun 5th, 2006, 8:27 AM   #4
dpsleep
Newbie
 
Join Date: May 2006
Posts: 16
Rep Power: 0 dpsleep is on a distinguished road
ok well i got it working now by useing
list($width, $height, $type, $attr) = getimagesize($artwork);
if ($type == "2"){
$albumart = imagecreatefromjpeg($artwork);
}elseif($type == "3"){
$albumart = imagecreatefrompng($artwork);
}
works good, thanks for trying
dpsleep
dpsleep is offline   Reply With Quote
Old Jun 5th, 2006, 8:32 AM   #5
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Quote:
ok i have no clue how this works
That sounds like you want me to hold your hand and pat your butt (and do it for you). You know why it sounds like that? Because you don't say shit. You don't say, "I tried this and I got these errors", or "I did this and my system barfed in its cuff." You need to go read the "How to Post a Question" thread, and maybe that "How to ask questions the smart way" that's referenced in the forum's FAQ. If you just don't know what the hell you're doing, that's okay, too, but just flat out say that.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jun 5th, 2006, 1:51 PM   #6
dpsleep
Newbie
 
Join Date: May 2006
Posts: 16
Rep Power: 0 dpsleep is on a distinguished road
Quote:
Originally Posted by DaWei
That sounds like you want me to hold your hand and pat your butt (and do it for you). You know why it sounds like that? Because you don't say shit. You don't say, "I tried this and I got these errors", or "I did this and my system barfed in its cuff." You need to go read the "How to Post a Question" thread, and maybe that "How to ask questions the smart way" that's referenced in the forum's FAQ. If you just don't know what the hell you're doing, that's okay, too, but just flat out say that.
um.. i did tell you what was wrong, i dont know how to use the function, let alone load it since i have no clue what extention i have to load, its undocumented so there isnt anything i can do with it. now about this holding my hand and patting my butt? i dont need you to hold my hand or help me in a detailed manner, i never asked for that. all i wsa asking is if anyone knew a function that would tell me the type of image a was looking at, without looking at just the extention, but the actual file contents. now im thankfull for you trying to help me, but when i tell you that i cant use it cause its undocumented, and you blow up telling me your gonna pat my butt?!?! i figured out that getimagesize gives you the file type the way i needed. like i said, thanks for trying but you dont gotta get all pissy, i know what im doing and i was just asking for a quick point in the right direction, not for you to hold my hand and pat my butt.
dpsleep is offline   Reply With Quote
Old Jun 6th, 2006, 7:19 PM   #7
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
If you load the file into a string first, you can use the imagecreatefromstring function, which will automatically detect the file type.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jun 7th, 2006, 4:30 AM   #8
dpsleep
Newbie
 
Join Date: May 2006
Posts: 16
Rep Power: 0 dpsleep is on a distinguished road
Quote:
Originally Posted by Ooble
If you load the file into a string first, you can use the imagecreatefromstring function, which will automatically detect the file type.
oo cool, that works better. thanks for the help.
dpsleep is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:14 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC