Rosamunda
Rosamunda

Reputation: 14990

PHP: How can exif_imagetype() function accept JPG files (instead of JPEG ones)?

I'm using the PHP exif_imagetype() function, and trying to accept these types of images:

IMAGETYPE_PNG

IMAGETYPE_JPEG

IMAGETYPE_GIF

But there's no IMAGETYPE_JPG imagetype constant, so all .jpg files are not accepted. Is there any solution to this?

Upvotes: 0

Views: 1758

Answers (2)

user149341
user149341

Reputation:

There is no difference between .jpeg and .jpg files. You do not need to treat them separately.

JPG is an abbreviation for JPEG, originally only used on DOS systems which did not support filename extensions longer than three characters.

Upvotes: 1

RafH
RafH

Reputation: 4544

IMAGETYPE_JPEG works for files with extensions jpg and jpeg :

var_dump(exif_imagetype ( "abc.jpg" ) == IMAGETYPE_JPEG);
var_dump(exif_imagetype ( "abc.jpeg" ) == IMAGETYPE_JPEG);

outputs

bool(true)
bool(true)

Upvotes: 2

Related Questions