PHP Classes
elePHPant
Icontem

PHP Image cURL: Emulate getimagesize function remotely using cURL

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2014-06-08 (1 year ago) RSS 2.0 feedNot yet rated by the usersTotal: 496 This week: 1All time: 5,421 This week: 1,122Up
Version License PHP version Categories  
image-curl 1.0.1Custom (specified...5.4PHP 5, Graphics, Files and Folders, W...
Description Author  

This class can emulate getimagesize function remotely using cURL.

It can retrieve an image file from a remote server using the cURL extension to send HTTP requests to that server.

The class implements a function that works like the original PHP getimagesize, except that it works for getting the image size and image type metadata of images retrieved from remote servers where fopen wrappers are disabled in the PHP configuration.

Besides the original getimagesize function metadata, it also returns the image file size.

Innovation Award  
PHP Programming Innovation award nominee
May 2014
Number 2


Prize: One copy of the Zend Studio
The getimagesize function is very useful to get the dimensions of images read from local or remote files.

However, if the fopen wrappers are disabled in the current PHP configuration, getimagesize cannot get the dimensions of remote images.

This class implements an alternative solution that relies only on the cURL extension.

Manuel Lemos
Picture of Mike Jordan
Name: Mike Jordan <contact>
Classes: 5 packages by
Country: United States United States
Age: 52
All time rank: 1686225 in United States United States
Week rank: 412 Up45 in United States United States Up
Innovation award
Innovation award
Nominee: 1x

Details provided by the author  
App:       Image cURL
Version:   1.0.0
Author:    MT Jordan <mtjo62@gmail.com>
Copyright: 2014
License:   zlib/libpng License

**********************************************************************************

Image cURL: Image class to simulate the getimagesize() function using the cURL library

Image cURL is a class that utilizes the cURL and GD libraries to simulate the getimagesize function where webhost have disabled the fopen wrappers. Image cURL is a "drop in" replacement that returns an array with the exact elements. Additionally, the image filesize is returned. This class is useful when requiring information from remote linked images to check filesizes and image dimensions for publishing restrictions.

*********************************************************************************

Image cURL Features:

    * Drop in replacement for the getimagesize function where the fopen wrappers are disabled.
    * Useful for getting image dimensional information when using the GD library.

Image cURL Restrictions:

    * Number of colors is returned instead of bits. cURL cannot supply this info.
    * Colors returns an unsigned integer for 8 bit palette-based images.
    * Colors returns 0 for 16+ bit true color images.	
 
Image cURL Requirements:

    * PHP 5.4+
    * Enabled GD extension
    * Enabled cURL extension

*********************************************************************************
  Files folder image Files  
File Role Description
Plain text file img_info.php Class Image class to simulate the getimagesize function
Accessible without login Plain text file license.txt Lic. zlib/libpng License
Accessible without login Plain text file readme.txt Data Class Information
Accessible without login Plain text file test_img_info.php Example Demo script

 Version Control Reuses Unique User Downloads Download Rankings  
 0%1Total:496All time:5,421
 This week:1This week:1,122Up
 User Comments (1)