Andrew Schmitt
Andrew Schmitt

Reputation: 31

PHP GD text wraps differently in browser than in created file

My text wraps great when its rendered in the browser: http://www.morriescontests.com/index.php/view/page/image

But when the same code simply creates and saves a new file it doesn't: http://www.morriescontests.com/images/uploads/32-142.png

This obviously makes me incredibly sad :(

They are separate scripts, one was for testing. The script that doesn't wrap correctly only has one difference, no headers are sent (obvi). I'm using the imgpng($image, $filename) function.

both scripts are on the same server, here is the last line of code:

// create image
header("Content-type: image/png"); // this is omitted from the incorrect wrapping script
// send to browser
imagepng($img); // this is omitted from the incorrect wrapping script
// save to file
$filepath = "the/path/image.png";
imagepng($img, $filepath);
imagedestroy($img);

Upvotes: 1

Views: 111

Answers (1)

Sabeen Malik
Sabeen Malik

Reputation: 10880

So did some investigation, you are using the path

http://www.morriescontests.com/billboardImage.php?caption=LONG%20STRING%20WRAP%20TEST,%20HMMMM%20I%20WONDER%20WHAT%20WILL%20HAPPEN%20NOW?&first_name=Andrew&last_initial=S.&city=Red%20Bank&user_id=32&id=128

to generate the image but the image you were looking at was 32-142.png

so i changed the url to

http://www.morriescontests.com/billboardImage.php?caption=LONG%20STRING%20WRAP%20TEST,%20HMMMM%20I%20WONDER%20WHAT%20WILL%20HAPPEN%20NOW?&first_name=Andrew&last_initial=S.&city=Red%20Bank&user_id=32&id=142

notice the id=142 and it works ok now. So it seems like the 32-142.png image you were seeing was created previously :)

Upvotes: 1

Related Questions