Jump to content


Photo

Curl / GD not working, pulling my hair out!


  • Please log in to reply
1 reply to this topic

#1 markswift

markswift

    Newbie

  • Member
  • Pip
  • 1 posts
  • Main OS: Windows 7

Posted 17 April 2015 - 03:48 AM

Hi Guys,

 

I have the latest version of Uniserver ZeroXL installed and running. I've transferred across from XAMPP and I wanted something lighter and less bloated.

 

The only issue I'm having is that one of my PHP scripts relies on curl and GD to pull images from my IP camera, sadly I cannot get this to work using Uniserver - it works fine with the default install of XAMPP.

 

The message displayed is attached, I've also ensured that both curl and GD are ticked under PHP modules.

 

Any help getting this resolved would be greatly appreciated, I've spent hours googling around and trying various things with no luck...

 

I also tried the following code in check.php and it just displays a blank page.

<?
// is curl installed?
if (!function_exists('curl_init')){ 
die('CURL is not installed!');
}

// create a new curl resource
$ch = curl_init();
echo "OK";
?>

Attached Files



#2 Ric

Ric

    Project Manager

  • Admin
  • PipPipPipPipPip
  • 1,535 posts
  • Gender:Male
  • Location:Cambridge,UK
  • Interests:Electronics
    Internet in general
    Open source projects
  • SourceForge IDmpgcan
  • Wiki ID: Ric
  • Main OS: Windows XP

Posted 17 April 2015 - 05:33 PM

The above example code will not work because you are using short PHP tags Uniform Server defaults to using full PHP tags.

 

The following examples show curl and gd operation on a default installation 11_7_4_ZeroXI

 

curl example save as file z2.php

<?php
$image_url = "http://www.uniformserver.com/ZeroXI_documentation/common/images/us_zero_logo.png";
$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $image_url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);

// Getting binary data
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);

$image = curl_exec($ch);
curl_close($ch);

// output to browser
header("Content-type: image/png");
print $image;
?>

gd example save as file z3.php

<?php
    header("content-type: image/png");
    $src_img = imagecreatefrompng("images/logo.png");
    $srcsize = getimagesize("images/logo.png");
    $dest_x = $srcsize[0] / 2;
    $dest_y = $srcsize[1] / 2;
    $dst_img = imagecreatetruecolor($dest_x, $dest_y);

    imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $dest_x, $dest_y, $srcsize[0], $srcsize[1]);
    imagepng($dst_img);
    imagedestroy($src_img);
    imagedestroy($dst_img);
?>

To run type http://localhost/z2.php and http://localhost/z3.php

 

All the best

Ric






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users