getimagesize() is among those traditional PHP features which highlights just how poor the calling convention for PHP features is. Generally If feature names in PHP are different by as well as emphasize (e.g. it would certainly be get_image_size()) yet this is one of those features that does not, words. Anyhow, I swerve ...
Pass getimagesize() a filename and also it will certainly return a selection having the picture's size, elevation, what kind of picture it is, a message worth with the size and also elevation which can be positioned straight right into an tag as well as a few other things outlined listed below.
For instance, if we had a JPEG photo called "my-great-photo. jpg" as well as it was 300 pixels size as well as 200 pixels high, you might obtain the photo details from it thus:$information = getimagesize("my-great-photo. jpg"); Doing print_r($information) would certainly return this, for the above instance:
Range( <0> => 300 <1> => 200 <2> => 2 <3> => size="300" elevation="200"
The worth in index 2 is just one of the IMAGETYPE_XXX constants, such as IMAGETYPE_GIF, IMAGETYPE_JPEG, imagetype_bmp and also imagetype_png. The worth in index 3 is the message string that can be include right into an tag.The 'little bits' worth shows the variety of little bits for each and every shade.
The 'networks' worth is either 3 for RGB or 4 for CMYK.The 'comedian' worth is the photo's comedian kind as well as can be utilized in an HTTP Content-type header.If the data can not be opened up or analyzed, the getimagesize() feature will certainly return incorrect. If accessing the filename photo is difficult, or if it isn't a legitimate image, getimagesize() will certainly create a mistake of degree E_WARNING. On read mistake, getimagesize() will certainly create a mistake of degree E_NOTICE.