andy's php projects
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Script and site usage:
All of the scripts on this site are provided free for non-commerical, personal or non-profit use. If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh? If you wish to use any of these in a commercial system, please refer to the payment plan.


Images too large to process?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Drop Shadowed Thumbnail Creator
View previous topic :: View next topic  
Author Message
motionbliss
Newbie


Joined: 11 Jul 2005
Posts: 21

PostPosted: Tue May 23, 2006 6:04 pm    Post subject: Images too large to process? Reply with quote

I've got an odd one that I could use your thoughts on Andy!

My web host recently moved me to a different box, and I've had some bad fallout because of it. One of the issues that I'm left with is why I can't seem to create dropshadows for large images any longer.

Example:
Works for 640x480 image...
http://travelvice.com/support/alterimage.php?url=http://snapshots.travelvice.com/download/6460-2/IMG_3343.JPG

But doesn't work for a 1600x1200 image...
http://travelvice.com/support/alterimage.php?url=http://snapshots.travelvice.com/download/6458-1/IMG_3343.JPG

Code for alterimage.php:

Code:

<?php

   require "class.dropshadow.php";

   $local = $_GET['img'];
   $url = $_GET['url'];
   
   $picture = new dropShadow(FALSE);
   $picture->setShadowPath('/home/craig/public_html/images/drop_shadow/');

   if (isset($local)) {
      $imageType = strtolower(substr($local, -3));
      $picture->loadImage('/home/craig/public_html/images/post_pics/'.$local);       
   } elseif (isset($url)) {
      //check for (and remove) Gallery 2 session marker
      $g2pos = strpos($url, '?g2_GALLERYSID');
      if ($g2pos !== false) {
         $url = substr($url, 0, $g2pos);
      }
      $imageType = strtolower(substr($url, -3));
      $picture->loadImageFromString(file_get_contents($url));
   }
   if (isset($resize)) {
      list($width, $height) = explode(',', $resize);
      $picture->resizeToSize($width,$height);
   }
   if (isset($noshadow)) {
      $picture->showFinal($imageType, 90);
   } else {
      $picture->applyShadow('FFFFFF');
      $picture->showShadow($imageType, 90);
   }
?>


Any ideas?
Back to top
View user's profile Send private message Visit poster's website
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Thu May 25, 2006 4:37 am    Post subject: Reply with quote

Hmm.. Well, it's not kicking back any error messages, so you could try setting the error reporting level to capture everything:

http://uk.php.net/manual/en/function.error-reporting.php

Or perhaps they're being written to the php error log? Check that out if you can.

You might be running our of the set amount of memory you have for each script to run in. You can check this in the phpinfo() output. Try adjusting that with the ini_set function:

PHP:
<?php ini_set('memory_limit''16M'?>


http://uk.php.net/manual/en/function.ini-set.php
http://uk.php.net/manual/en/ini.php#ini.list

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
motionbliss
Newbie


Joined: 11 Jul 2005
Posts: 21

PostPosted: Thu May 25, 2006 11:26 am    Post subject: Reply with quote

How does the config look on their server? Everything in order?
http://travelvice.com/info.php
Back to top
View user's profile Send private message Visit poster's website
motionbliss
Newbie


Joined: 11 Jul 2005
Posts: 21

PostPosted: Thu May 25, 2006 11:35 am    Post subject: Reply with quote

amnuts wrote:
Try adjusting that with the ini_set function:

PHP:
<?php ini_set('memory_limit''16M'?>




OK -- this is in place, but doesn't seem to be having any effect... Neutral
Back to top
View user's profile Send private message Visit poster's website
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Thu May 25, 2006 1:36 pm    Post subject: Reply with quote

Everything seems OK, and it was rendering 1024x768 or so images from flickr just fine, but a couple hundred pixels above that and it's crapping out. Have you tried setting the error_reporting to E_ALL?
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
motionbliss
Newbie


Joined: 11 Jul 2005
Posts: 21

PostPosted: Sat May 27, 2006 1:28 pm    Post subject: Reply with quote

When I tried that I got (for the larger image):

Code:
Notice: Undefined index: img in /home/craig/public_html/support/alterimage.php on line 24


I'm at a loss... Confused
Back to top
View user's profile Send private message Visit poster's website
motionbliss
Newbie


Joined: 11 Jul 2005
Posts: 21

PostPosted: Tue Jun 13, 2006 4:09 pm    Post subject: Reply with quote

Hey there Andy,

Anything you can think of that I could ask my hosting company about that might shed some light on this? Question
Back to top
View user's profile Send private message Visit poster's website
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Mon Jun 19, 2006 5:24 pm    Post subject: Reply with quote

I'm sorry, mate, I don't know. I've been tring to see if perhaps GD or getting the remote file has some kind of limit, but haven't come up with anything. I'd certainly be interested if you do.

Have you tried opening from a local store the same size file that you're having problems with remotely?
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
motionbliss
Newbie


Joined: 11 Jul 2005
Posts: 21

PostPosted: Sat Jun 24, 2006 9:26 pm    Post subject: Reply with quote

yeah, tried... and still failed. Sad

I'll let you know if the host comes up with anything.

Thanks Andy!
Back to top
View user's profile Send private message Visit poster's website
motionbliss
Newbie


Joined: 11 Jul 2005
Posts: 21

PostPosted: Tue Jun 27, 2006 3:40 pm    Post subject: Reply with quote

Would you be able to help me reply to the host?

Quote:
Dear Craig,
I took at look at your script but I'm not entirely sure how it works. I see you use a "class.dropshadow.php" as you can imagine that isn't very helpful. I looked at that file briefly but I nothing really jumped out at me. Are you use the imagemagick libraries? Or something similar? If that's the case I could try to reinstall those libraries or examine them to see if they have become corrupt.

The bottom line is we really don't know how your script works so it's tough for us to assist you. If you would please provide us with some background information perhaps we can be of more assistance.
Back to top
View user's profile Send private message Visit poster's website
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Tue Jun 27, 2006 5:23 pm    Post subject: Reply with quote

Basically; the class uses the GD image library which comes standard with installations of PHP since 4.3.0. In your instance it's using the jpeg libraries to load and save the images. You're loading the image via file url wrappers (file_get_contents with a full url supplied), but this isn't part of the class, simply part of PHP.

I shouldn't think that the libraries need reinstalling because it works for other smaller images, which brings me to a possible cause of the issue...

I've just tried it on my machine loading the image locally and loading from your site, and I've tried it on my work machine loading from your site - all instances worked just fine and displayed the image. But what I did notice was an appreciatable length of time to fetch and process the larger image. What might be happening is that the length of time taken to do this for you is longer than the defined length of time a php script can run for (as set in the php.ini file), and you may have all errors going to the error log file (again, set in the php.ini file) instead of on screen. If that's the case then it's very likely that you are having warning/error messages but they're just being redirected to the file and so you never see them on screen.

So try adjusting with the set_time_limit function:

http://uk.php.net/set_time_limit

see if that helps any.

It might also be to do with the file_get_contents portion of alterimage.php. You could try changing that for a more socket-based approach, such as:

Code:
function getImage($domain, $path)
{
    $errno  = 0;
    $errstr = '';
    $image  = '';
    $socket = fsockopen($domain, 80, $errno, $errstr, 60);
    if ($socket) {
        fputs($socket, "GET $path HTTP/1.0\r\nHost: $domain\r\nUser-Agent: ImageFetch\r\n\r\n");
        while (!feof($socket)) {
            $line .= fgets($socket, 4096);
        }
        fclose($socket);
    }
    return $image;
}


then your line in alterimage.php would look something like:

Code:
$img = getImage('snapshots.travelvice.com', '/download/6458-1/IMG_3343.JPG');
$picture->loadImageFromString($img);


I've not tested it, but it might be worth a go (similar technique to what I use the in cafe press class).

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
motionbliss
Newbie


Joined: 11 Jul 2005
Posts: 21

PostPosted: Sun Jul 02, 2006 4:40 pm    Post subject: Reply with quote

Hummm, the set time limit function doesn't look like it's doing anything different.

The only thing I see in the error log is this...

Code:

[30-Jun-2006 17:57:32] PHP Warning:  imagesy(): supplied argument is not a valid Image resource in /home/craig/public_html/support/class.dropshadow.php on line 394
[30-Jun-2006 17:57:32] PHP Warning:  imagesx(): supplied argument is not a valid Image resource in /home/craig/public_html/support/class.dropshadow.php on line 394
[30-Jun-2006 17:57:32] PHP Warning:  Division by zero in /home/craig/public_html/support/class.dropshadow.php on line 394


I can't seem in to recreate the error that causes the population/generation of the error log, but it is happening occasionally for some reason... still looking into that.

Will give the socket idea a shot... Smile

Thanks for the brain power Andy!
Back to top
View user's profile Send private message Visit poster's website
kimosabi
Newbie


Joined: 23 Aug 2006
Posts: 2

PostPosted: Sat Aug 26, 2006 10:24 pm    Post subject: Reply with quote

I had exactly the same problem. I increased the memory_limiy value to 16M in php for the particular vhost and it fixed it.

Cheers,
Kim
Back to top
View user's profile Send private message
motionbliss
Newbie


Joined: 11 Jul 2005
Posts: 21

PostPosted: Mon Sep 04, 2006 7:53 pm    Post subject: Reply with quote

Where should I try dropping that setting again? Inside the class.dropshadow.php file?
Back to top
View user's profile Send private message Visit poster's website
kimosabi
Newbie


Joined: 23 Aug 2006
Posts: 2

PostPosted: Mon Sep 11, 2006 5:13 pm    Post subject: Reply with quote

I just set it using ini_set('memory_limit','16M') at the top of the script that calls class.dropshadow
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Drop Shadowed Thumbnail Creator All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group