Jump to content

Is there a function to resize images ?


tmyonline

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

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);

  }

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.