Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I get this error when running the following code:

No such file found at "widgets/104-text.png"

I know that the code works because it works on my other non-ubuntu server. I do not know if it is gd library or what. I tried both the bundled version and the non-bundled and both do not make this code work.

$con = mysql_connect("localhost","user","abc123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("satabase_name", $con);

$productid2 = $this->product->id;


$thename = mysql_query("SELECT * FROM pshop_product_lang WHERE id_product = '$productid2' LIMIT 1");


$thename2 = mysql_fetch_array($thename);


$string2 = $thename2['name'];


$string = (strlen($string2) > 25) ? substr($string2, 0, 25) . '...' : $string2;

$font  = 4;
$width  = imagefontwidth($font) * strlen($string);
$height = imagefontheight($font);

$image = imagecreatetruecolor ($width,$height);
$white = imagecolorallocate ($image,255,255,255);
$black = imagecolorallocate ($image,0,0,0);
imagefill($image,0,0,$white);

imagestring($image,$font,0,0,$string, $black);

imagepng($image, 'widgets/' . $productid2 . '-text.png');



$getimg110 = mysql_query("SELECT * FROM pshop_image WHERE id_product = '$productid2'");

$gotimg110 = mysql_fetch_array($getimg110);

$slash110 = addcslashes($gotimg110[id_image], '\0..\999999999999999999999');

$str110 = str_replace('\\', '/', $slash110); 

$newimg110 = '<img src="img/p' . $str110 . '/' . $gotimg110[id_image] . '-large_default.jpg" />';


include("conf.inc.php");

include('ImageWorkshop.php');


// Initialization of layer you need
$pinguLayer = new ImageWorkshop(array(
'imageFromPath' => 'widgets/background.png',
));



$pinguLayer2 = new ImageWorkshop(array(
'imageFromPath' => 'img/p' . $str110 . '/' . $gotimg110[id_image] . '-large_default.jpg',
));

$pinguLayer3 = new ImageWorkshop(array(
'imageFromPath' => 'widgets/' . $productid2 . '-text.png',
));

// resize pingu layer
$thumbWidth2 = 150; // px
$thumbHeight2 = 150;

$thumbWidth = 400; // px
$thumbHeight = 200;




$pinguLayer2->resizeInPixel($thumbWidth2, $thumbHeight2);
$pinguLayer->resizeInPixel($thumbWidth, $thumbHeight);

// Add 2 layers on pingu layer
$pinguLayer->addLayerOnTop($pinguLayer2, null, null, 'LM');
$pinguLayer->addLayerOnTop($pinguLayer3,  70, 25, 'MM');


// Saving the result in a folder
$pinguLayer->save("widgets/", $productid2 . ".gif", true, null, 95);

The file path is correct, however this part of the code is not creating the image as it is supposed to:

$thename2 = mysql_fetch_array($thename);


$string2 = $thename2['name'];


$string = (strlen($string2) > 25) ? substr($string2, 0, 25) . '...' : $string2;

$font  = 4;
$width  = imagefontwidth($font) * strlen($string);
$height = imagefontheight($font);

$image = imagecreatetruecolor ($width,$height);
$white = imagecolorallocate ($image,255,255,255);
$black = imagecolorallocate ($image,0,0,0);
imagefill($image,0,0,$white);

imagestring($image,$font,0,0,$string, $black);

imagepng($image, 'widgets/' . $productid2 . '-text.png');
share|improve this question
    
You may have better luck with this on StackOverflow. –  mfisch Dec 12 '12 at 2:48
    
You sure it's ok for me to post it there too? Also, it seems like it is a server issue. Because it works on my non-ubuntu server. –  Derrick Dec 12 '12 at 4:05
    
It's really lacking enough context to be useful here. I don't even know what language that is, PERL maybe? I don't know how to run it, I don't know what dependencies it has and I don't know what it's supposed to do. –  mfisch Dec 12 '12 at 4:41
    
watch the error log, and debug the variables to see what you pass to gd functions. –  Elvis Jan 7 '13 at 13:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.