Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How to check what image's format
Old 10-05-2008, 09:41 AM How to check what image's format
Novice Talker

Posts: 8
Trades: 0
How to check what image's format

Last edited by elizool99; 10-05-2008 at 09:45 AM..
elizool99 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-05-2008, 02:40 PM Re: How to check what image's format
Junior Talker

Posts: 1
Trades: 0
There are serveral methods to check image format.

You can explode image filename by "." (dot) and take last element of result array.

Ex.

$image = 'abce.jpg';

$imarr = explode('.',$image);

$imgformat = $imarr[sizeof($imarr)-1];

I hope you may solved your problem using this.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
archanapatel is offline
Reply With Quote
View Public Profile
 
Old 10-06-2008, 03:53 AM Re: How to check what image's format
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
getimagesize()
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 10-29-2008, 04:25 AM Re: How to check what image's format
Junior Talker

Posts: 1
Trades: 0
I am fully agree with the user archanapatel, and You can explode image filename by "." (dot) and take last element of result array.

Ex.

$image = 'abce.jpg';

$imarr = explode('.',$image);

$imgformat = $imarr[sizeof($imarr)-1];

I hope you may solved your problem using this.

and the user mtishetsky is totally wronge.
__________________

Please login or register to view this content. Registration is FREE
Open Source is offline
Reply With Quote
View Public Profile
 
Old 10-29-2008, 04:38 AM Re: How to check what image's format
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Maybe you should read up on getimagesize()

The "solution" you think is correct would only get the filename extension NOT the image format. So archanapatel and you are both wrong.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-29-2008, 05:13 AM Re: How to check what image's format
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
The "solution" you think is correct would only get the filename extension NOT the image format. So archanapatel and you are both wrong.
Absolutely!
Try to rename an jpg image to gif, and to open it in firefox. It will be displayed correctly.
A file is defined by it's content, not it's extension (except for window, but they surely will say that's a feature, and not a bug).

Linux/osx systems use what is called "the magic file", which gives content pattern and signatures to determine the mime type of a file based on it's content and not it's extension.

getimagesize() does exactly that; it parse the content of the file to determine it's mime type and dimensions.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to How to check what image's format
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22700 seconds with 12 queries