tmyonline Posted November 15, 2007 Share Posted November 15, 2007 Hi guys: I need to resize images for my current work. I used the function "getimagesize()" which works fine on my local machine but somehow fails to work on the server after I uploaded. As a result, the images do not appear online although they do appear locally on my machine. How should I resolve this? Otherwise, is there a function to get the width and the height of an image? Thanks a lot. T Quote Link to comment Share on other sites More sharing options...
obsidian Posted November 15, 2007 Share Posted November 15, 2007 What version of PHP is running on your server? Also, what errors are you getting when you try to use it? Quote Link to comment Share on other sites More sharing options...
tmyonline Posted November 15, 2007 Author Share Posted November 15, 2007 Hi, thanks for helping me! I'm not sure what version of PHP is running on the server. I can ask but the lady here just walked out. On my machine, it's PHP 5 that is running but not sure what's on the server. Here are the messages I got: Warning: getimagesize() [function.getimagesize]: URL file-access is disabled in the server configuration in /home/.euclid/aamnva/actualaamnva.org/schools/test/lereport.php on line 106 Warning: getimagesize(http://memory.loc.gov/pnp/fsa/8c03000/8c03800/8c03875r.jpg) [function.getimagesize]: failed to open stream: no suitable wrapper could be found in /home/.euclid/aamnva/actualaamnva.org/schools/test/lereport.php on line 106 Thanks. T Quote Link to comment Share on other sites More sharing options...
obsidian Posted November 15, 2007 Share Posted November 15, 2007 OK, so the function is installed, so PHP version shouldn't matter. How are you referencing the image? Can you show your code snippet you are using for the getimagesize() call? Quote Link to comment Share on other sites More sharing options...
tmyonline Posted November 15, 2007 Author Share Posted November 15, 2007 Here's my code for this: list($width, $height) = getimagesize($imageSelect); if ($width != 500) { $width = 500; $height = 500 * ($height/$width); } if ($height > 500) { $height = 500; $width = 500 * ($width/$height); } I also tried: list($width, $height, $attribute, $type) = getimagesize($imageSelect); Quote Link to comment Share on other sites More sharing options...
tmyonline Posted November 15, 2007 Author Share Posted November 15, 2007 Here's how I referenced the images: $imgSQL = "SELECT * FROM LOC_item WHERE LOC_key = $LOCKEY AND image like 'http%'"; $imgResult = mysql_db_query($db,$imgSQL,$cid); $imgRow = @mysql_fetch_assoc($imgResult); $imageSelect = $imgRow['image']; list($width, $height) = getimagesize($imageSelect); if ($width != 500) { $width = 500; $height = 500 * ($height/$width); } if ($height > 500) { $height = 500; $width = 500 * ($width/$height); } Quote Link to comment Share on other sites More sharing options...
obsidian Posted November 15, 2007 Share Posted November 15, 2007 There's your problem... you are referencing your images via a URL path based on your query. This means that, most likely, you do not have the allow_url_fopen flag set to "on." Otherwise, you have to be able to reference your images via their server path instead. Quote Link to comment Share on other sites More sharing options...
tmyonline Posted November 15, 2007 Author Share Posted November 15, 2007 The images are working and displaying fine on my local machine; they just do not appear online. In other words, the "getimagesize()" function works fine on my computer but not on the server. So, How do I set the "allow_url_fopen" flag to "on" ? and, how do I reference images via server path ? Any other alternatives to resize images or get their width and height? Thanks, T. Quote Link to comment Share on other sites More sharing options...
obsidian Posted November 15, 2007 Share Posted November 15, 2007 If you'll read the manual page on that setting I linked to, you'll see a note that, due to security reasons, that flag can only be set within the php.ini file on the server. Most likely, your local copy (especially if you're using WAMP, XAMPP or one of the cousins) will have that flag set to "on." You'll need to get your system administrator to change the setting in the php.ini for you. If you would rather reference via server path, it would be the absolute path to the image directory in which you are storing the images (ie, /usr/local/apache/htdocs/images/ or whatever your setup is). The only other way I can think of to get the image size (and this is a hack) would be to display the image and use javascript to measure it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.