GithubHelp home page GithubHelp logo

fastimage's Introduction

FastImage

FastImage finds the dimensions or filetype of a remote image file given its uri by fetching as little as needed, based on the excellent Ruby implementation by Stephen Sykes.

Usage

<?php 
		
require 'Fastimage.php';
		
$uri = "http://farm9.staticflickr.com/8151/7357346052_54b8944f23_b.jpg";
		
// loading image into constructor
$image = new FastImage($uri);
list($width, $height) = $image->getSize();
echo "dimensions: " . $width . "x" . $height;

// or, create an instance and use the 'load' method
$image = new FastImage();
$image->load($uri);
$type = $image->getType();
echo "filetype: " . $type;

References

License

FastImage is released under the MIT license. It is simple and easy to understand and places almost no restrictions on what you can do with the software. More Information

Download

Releases are available for download from GitHub.

fastimage's People

Contributors

bmitch avatar jdreesen avatar nicolas-grekas avatar tommoor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fastimage's Issues

Cannot detect JPEG images on some platforms

I'm using fastimage in my project KCFinder. It works perfectly on my Windows workstation, but when I tried on Linux server, fastimage cannot detect the JPEG images (PNG and GIF works fine).

Windows workstation:
Windows 7 (64bit)
Apache/2.4.7
PHP 5.5.9

Linux server:
Gentoo Linux (64bit)
Apache/2.2.25
PHP 5.4.26

not working?

Thanks for your efforts, but it does not seem like the library is working? when i run the below function what i get is:

=======> http://www.google.com.eg/images/srpr/logo3w.png <======

FastImage:
Width: px Height: px in 0.92465806007385 seconds
Getimagesize:
Width: 275px Height: 95px in 0.47799015045166 seconds
=======> http://pcdn.500px.net/8123858/7051e2440a869a3fec74406a3aa200618452c390/4.jpg <======
FastImage:
Width: px Height: px in 1.06796002388 seconds
Getimagesize:
Width: 900px Height: 900px in 4.6637139320374 seconds
=======> http://farm3.staticflickr.com/2019/2354671896_8216677d61_o.jpg <======
FastImage:
Width: px Height: px in 1.3999531269073 seconds
Getimagesize:
Width: 1417px Height: 1063px in 7.8245828151703 seconds
=======> http://farm1.staticflickr.com/100/306618144_c2810214ee_b.jpg <======
FastImage:
Width: px Height: px in 4.7077901363373 seconds
Getimagesize:
Width: 1024px Height: 768px in 6.2303919792175 seconds

function GetSizeTest(){
  $path = libraries_get_path('fastimage');
  require_once($path."/Fastimage.php");

  $files = array(
    'http://www.google.com.eg/images/srpr/logo3w.png',
    'http://pcdn.500px.net/8123858/7051e2440a869a3fec74406a3aa200618452c390/4.jpg',
    'http://farm3.staticflickr.com/2019/2354671896_8216677d61_o.jpg',
    'http://farm1.staticflickr.com/100/306618144_c2810214ee_b.jpg'
  );

  foreach($files as $file){
    $uri = $file;
    echo "=======> $uri <======\n";
    $time = microtime(true);
    $image = new FastImage($uri);
    $image->load($uri);
    echo ">FastImage: \n";
    $size = $image->getSize();
    dsm($size);
    list($width, $height) = $size;
    echo "Width: ". $width . "px Height: ". $height . "px in " . (microtime(true)-$time) . " seconds \n";

    $time = microtime(true);
    list($width, $height) = getimagesize($uri);
    echo ">Getimagesize: \n";
    echo "Width: ". $width . "px Height: ". $height . "px in " . (microtime(true)-$time) . " seconds \n";
  }
}

Am i doing anything wrong or something wrong with the library?

Slow on mine

I just tested to compare with getimagesize() function and the result also the same. Means maybe the network is the problem.

Detect ico files

I'd like fastimage could support icon files, at least in the getType() method (getSize is more complicated because the ico files can store more than one image with multiple sizes).
thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.