Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
Like Tree2Likes
  • 1 Post By mlseim
  • 1 Post By Glenn

Thread: Inspecting Images

  1. #1
    Senior Member
    Join Date
    Aug 2011
    Posts
    226
    Member #
    29153
    Liked
    4 times

    Inspecting Images

    I've created this to get the size of several images I have in a directory....

    $image = file_get_contents("$fileLocation");
    $source = imagecreatefromstring($image);

    $width = imagesx($source);
    $height = imagesy($source);
    echo " &nbsp; width : ", $width, " $nbsp; height : ", $height, "<br><br>";



    When it gets to an image with a name that has a space in the name, it gives me an error....

    Warning: imagecreatefromstring(): Data is not in a recognized format in /setupdb.php on line 23

    Warning: imagesx() expects parameter 1 to be resource, boolean given in /setupdb.php on line 25

    Warning: imagesy() expects parameter 1 to be resource, boolean given in /setupdb.php on line 26



    What do I need to add to get it to read them better?

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,686
    Member #
    5580
    Liked
    716 times
    Have you tried this yet?

    $image = file_get_contents($fileLocation);
    $source = imagecreatefromstring($image);

    Remove the quotes.

    Or, if that doesn't work, maybe this ...

    $fileLocation = str_replace(' ', '%20', $fileLocation); // replaces spaces with %20
    $image = file_get_contents($fileLocation);
    $source = imagecreatefromstring($image);
    sarahswansea likes this.


  4. #3
    Senior Member
    Join Date
    Aug 2011
    Posts
    226
    Member #
    29153
    Liked
    4 times
    Quote Originally Posted by mlseim View Post
    Have you tried this yet?

    $image = file_get_contents($fileLocation);
    $source = imagecreatefromstring($image);

    Remove the quotes.

    Or, if that doesn't work, maybe this ...

    $fileLocation = str_replace(' ', '%20', $fileLocation); // replaces spaces with %20
    $image = file_get_contents($fileLocation);
    $source = imagecreatefromstring($image);
    Yes! The str_replace worked. Thanks!
    sarahswansea likes this.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:56 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com