rim – PHP Remote Image Library

Author: Matej B. January 16, 2012

Working on recent home project I found there is no library in PHP to get dimensions of remote images.
So I made rim php library to get type and size of remote images in optimized way.

Fork it on github

The easiest way of getting a image dimension is by using getimagesize PHP function.
It has one great fault when working with remote images, whole image must be downloaded in order for getimagesize to read it’s dimensions.
So if you want to find out dimensions of jpeg 2MB in size getimagesize will first download it. There goes bandwidth!

Rim downloads only few byes need to determine image type and dimensions.
Also if you need to get dimensions of lot’s of pictures rim will thread fetch request for further speed increase.

Take a look at this benchmark, fetching image types and sizes of all images on Hot New Releases in Books at amazon.com:

Have fun!

Bug reports would be appreciated ;)

Matej B.
Follow me @matejbaco

    3 thoughts on “rim – PHP Remote Image Library”

  • Hey! This is great idea, but it doesn’t mork with SAFE MODE ON. Anyway to make it safe mode friendly? At the moment getimagesize is crazy slow on remote files and not really an option for my project…


  • @Marius: if you are on a hosting with safe mode – move now. :)

  • won’t work with the file with force-download
    i have reply for your class here:
    you can try

  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>