PHP Classes

PHP Image cURL: Emulate getimagesize function remotely using cURL

Recommend this page to a friend!
  Info   View files Example   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 652 All time: 4,914 This week: 102Up
Version License PHP version Categories
image-curl 2.0.3Custom (specified...5.4PHP 5, Graphics, Files and Folders, W...


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 as a wrapper for the PHP getimagesize method by retrieving the image file and calling getimagesize to get the image size and image type metadata of images retrieved from remote servers so it will work on PHP environments on which 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
  Performance   Level  
Name: Mike Jordan <contact>
Classes: 5 packages by
Country: United States United States
Age: 61
All time rank: 1461219 in United States United States
Week rank: 110 Up11 in United States United States Up
Innovation award
Innovation award
Nominee: 1x



include 'img_info.php';
$info = img_info::getimagesize( '' );
if ( !
$info )
'invalid image or URL';
print_r( $info );

//Returns: Array ( [0] => 80 [1] => 60 [2] => 2 [3] => width="80" height="60" [bits] => 8 [channels] => 3 [mime] => image/jpeg [size] => 1954 )


App: Image cURL Version: 2.1.0 Author: MT Jordan <> Copyright: 2016 License: zlib/libpng License ********************************************************************************** Image cURL: Image class to emulate the getimagesize() function using the cURL library Image cURL is a class that utilizes the cURL library as a handler for HTTP requests for remote images where web hosts have disabled the fopen wrappers. Additionally, the image filesize is returned. This class is useful when requiring metadata from remote linked images to check filesizes and image dimensions for publishing restrictions. ********************************************************************************* Image cURL Features: * Alternate method for the getimagesize function where the fopen wrappers are disabled. Image cURL Restrictions: * Image path MUST be a fully qualified URL. * Must have permissions to read/write to sys tmp dir Image cURL Requirements: * PHP 5.4+ * 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  
This week:0
All time:4,914
This week:102Up
User Comments (1)