![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: May 2006
Posts: 16
Rep Power: 0
![]() |
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.
|
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#3 |
|
Newbie
Join Date: May 2006
Posts: 16
Rep Power: 0
![]() |
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 8:47 AM. |
|
|
|
|
|
#4 |
|
Newbie
Join Date: May 2006
Posts: 16
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#5 | |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Quote:
__________________
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 |
|
|
|
|
|
|
#6 | |
|
Newbie
Join Date: May 2006
Posts: 16
Rep Power: 0
![]() |
Quote:
|
|
|
|
|
|
|
#7 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
If you load the file into a string first, you can use the imagecreatefromstring function, which will automatically detect the file type.
|
|
|
|
|
|
#8 | |
|
Newbie
Join Date: May 2006
Posts: 16
Rep Power: 0
![]() |
Quote:
|
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|