Processing a second time after first process?

See all posts Reply

Processing a second time after first process? new!
by Murray Summers, 13 years ago
Can I do something like this?

$handle->image_resize            = true;
$handle->image_ratio_y           = true;
$handle->image_x                 = 84;
$handle->image_border 		 = '1px';
$handle->image_border_color 	 = '#FFFFFF';
$handle->file_new_name_body 	 = substr($_POST['current1'],0,-4);
$handle->file_overwrite 	 = true;
$handle->Process($dir_dest);

// we check if everything went OK
if ($handle->processed) {
  $info = getimagesize($handle->file_dst_pathname);
  if ($info[1] > 70) $handle->image_crop = array(0,0,($info[1]-70),0);
    $handle->Process($dir_dest);
Reply
Re: Processing a second time after first process? new!
by colin, 13 years ago
Yes, you can.

However, you'd better use $handle->image_dst_y rather than calling getimagesize()Reply
Re: Processing a second time after first process? new!
by Murray Summers, 13 years ago
Thanks! Here's what I have now -

if ($handle->uploaded) {
  // we now process the image a second time, with some other settings
  $handle->image_resize        = true;
  $handle->image_ratio_y       = true;
  $handle->image_x             = 84;
  $handle->image_border        = '1px';
  $handle->image_border_color  = '#FFFFFF';
  $handle->file_new_name_body  = substr($_POST['current1'],0,-4);
  $handle->file_overwrite      = true;
  $handle->Process($dir_dest);

  // we check if everything went OK
  if ($handle->processed) {
  if ($handle->image_dst_y > 70) $handle->image_crop = array(0,0,($handle->image_dst_y - 70),0);
  $handle->Process($dir_dest);

It's giving me a timeout error -
PHP Fatal error: Maximum execution time of 30 seconds exceeded in W:\...\_class\class.upload.php on line 4844Reply
Re: Processing a second time after first process? new!
by colin, 13 years ago
You need to increase the maximum execution time of your script. You can use the PHP function set_time_limit() or change max_execution_time value defined in the php.iniReply
Re: Processing a second time after first process? new!
by Murray Summers, 13 years ago
Can you explain why this should involve any extra time? After all, the original image has already been uploaded and moved. It just needs to be reprocessed, right?Reply
Re: Processing a second time after first process? new!
by colin, 13 years ago
The time needed is for processing. The upload time is not counted in. It looks like your server must be a little bit slow if it cannot do two processing within 30 secondsReply
Re: Processing a second time after first process? new!
by Murray Summers, 13 years ago
Got it! I needed to restate some of the initial variables again. My code now is this -
if ($handle->uploaded) {
  // we now process the image a second time, with some other settings
  $handle->image_resize        = true;
  $handle->image_ratio_y       = true;
  $handle->image_x             = 84;
  $handle->image_border        = '1px';
  $handle->image_border_color  = '#FFFFFF';
  $handle->file_new_name_body  = substr($_POST['current1'],0,-4);
  $handle->file_overwrite      = true;
  $handle->Process($dir_dest);

  // we check if everything went OK
  if ($handle->processed) {
    if ($handle->image_dst_y > 70) {
      $handle->image_crop = array(0,0,($handle->image_dst_y - 70),0);
      $handle->image_resize        = true;
      $handle->image_ratio_y       = true;
      $handle->image_x             = 84;
      $handle->image_border        = '1px';
      $handle->image_border_color  = '#FFFFFF';
      $handle->file_new_name_body  = substr($_POST['current1'],0,-4);
      $handle->file_overwrite      = true;
      $handle->Process($dir_dest);

That seems to work within the 30-second time limit.Reply