Fabis94 Posted July 17, 2010 Share Posted July 17, 2010 I'm making a hiscore reader that outputs the scores in an image. Everything is working fine except that the text is ugly and pixelated no matter what size i use. I use GD with PHP. What could be the problem? Quote Link to comment https://forums.phpfreaks.com/topic/208048-text-outputted-with-gd-is-pixelated-and-ugly/ Share on other sites More sharing options...
Alex Posted July 17, 2010 Share Posted July 17, 2010 Using the image*() function (depending on your format, png, jpeg, etc.. whichever one you're using) you can specify the quality of the image. Trying increases the quality. Quote Link to comment https://forums.phpfreaks.com/topic/208048-text-outputted-with-gd-is-pixelated-and-ugly/#findComment-1087551 Share on other sites More sharing options...
.josh Posted July 17, 2010 Share Posted July 17, 2010 Ah yes, I see your problem. It's on line 5. Quote Link to comment https://forums.phpfreaks.com/topic/208048-text-outputted-with-gd-is-pixelated-and-ugly/#findComment-1087552 Share on other sites More sharing options...
Fabis94 Posted July 17, 2010 Author Share Posted July 17, 2010 Using the image*() function (depending on your format, png, jpeg, etc.. whichever one you're using) you can specify the quality of the image. Trying increases the quality. What do you mean? I don't see an argument for changing the quality :/ EDIT: Nvm found it, but it requires you to save the file. I don't need to save the file. Also on my own computer (when i run stuff on localhost) everything looks fine, but when i transfer it to another server the text looks completely different. What's wrong? Quote Link to comment https://forums.phpfreaks.com/topic/208048-text-outputted-with-gd-is-pixelated-and-ugly/#findComment-1087575 Share on other sites More sharing options...
.josh Posted July 17, 2010 Share Posted July 17, 2010 my guess is that you are trying to use a font that is not available on your server. But again, seeing as how you have yet to actually provide real details, it's only a guess. Quote Link to comment https://forums.phpfreaks.com/topic/208048-text-outputted-with-gd-is-pixelated-and-ugly/#findComment-1087580 Share on other sites More sharing options...
Fabis94 Posted July 17, 2010 Author Share Posted July 17, 2010 I have uploaded EVERYTHING. Which means that everything that i have on my PC is on the server (including the font). The text uses the font on the server, it's just that it's messed up. Here's how it looks on my PC: http://i26.tinypic.com/dvaer.png And here's how it looks on the server (remember, that all the files are uploaded): http://i26.tinypic.com/xdi7ft.png What i noticed is that the filesize is different aswell. So wtf Quote Link to comment https://forums.phpfreaks.com/topic/208048-text-outputted-with-gd-is-pixelated-and-ugly/#findComment-1087582 Share on other sites More sharing options...
Alex Posted July 17, 2010 Share Posted July 17, 2010 Using the image*() function (depending on your format, png, jpeg, etc.. whichever one you're using) you can specify the quality of the image. Trying increases the quality. What do you mean? I don't see an argument for changing the quality :/ EDIT: nevermind found it, but it requires you to save the file. I don't need to save the file. That's not true: The path to save the file to. If not set or NULL, the raw image stream will be outputted directly. You simply pass null as the second parameter, something like this: imagepng($im, null, 0); Quote Link to comment https://forums.phpfreaks.com/topic/208048-text-outputted-with-gd-is-pixelated-and-ugly/#findComment-1087594 Share on other sites More sharing options...
Fabis94 Posted July 17, 2010 Author Share Posted July 17, 2010 Yeah i found that, and i found out that quality isn't the problem. Look at my post before yours: I have uploaded EVERYTHING. Which means that everything that i have on my PC is on the server (including the font). The text uses the font on the server, it's just that it's messed up. Here's how it looks on my PC: http://i26.tinypic.com/dvaer.png And here's how it looks on the server (remember, that all the files are uploaded): http://i26.tinypic.com/xdi7ft.png What i noticed is that the filesize is different aswell. So wtf Quote Link to comment https://forums.phpfreaks.com/topic/208048-text-outputted-with-gd-is-pixelated-and-ugly/#findComment-1087597 Share on other sites More sharing options...
.josh Posted July 18, 2010 Share Posted July 18, 2010 I still think it's a problem with the font. Since you still haven't posted any code, I'm still just guessing here...I'm guessing you are using imagettfbbox and/or imagettftext? Are you using the same version of the GD library on your localhost as your server? If it is a different GD version you may need to adjust the path/to/fontfile and/or how you specify the font size (unit-wise). Quote Link to comment https://forums.phpfreaks.com/topic/208048-text-outputted-with-gd-is-pixelated-and-ugly/#findComment-1087646 Share on other sites More sharing options...
Fabis94 Posted July 20, 2010 Author Share Posted July 20, 2010 I found out that the versions are different. So how do i adjust the code to output the picture as it does on my computer? (my computer has a newer version). Ok and here's the code: header("Content-type: image/png"); $font = 'digitalix.ttf'; $textfont = 'lsans.ttf'; $fontsize = 8; $image = imagecreatetruecolor(350, 170); imageantialias($image, false); $base_img = imagecreatefrompng('base.PNG'); imagecopy($image, $base_img, 0, 0, 0, 0, 350, 170); $white = imagecolorallocate($image, 255, 255, 255); $black = imagecolorallocate($image, 0, 0, 0); (...) imagettftext($image, $fontsize, 0, 71, $y, $white, $font, $text); //One of the functions, no point of posting them all addBorder($image, 0, 0, 0); imagepng($image); imagedestroy($image); Quote Link to comment https://forums.phpfreaks.com/topic/208048-text-outputted-with-gd-is-pixelated-and-ugly/#findComment-1088646 Share on other sites More sharing options...
.josh Posted July 20, 2010 Share Posted July 20, 2010 okay well the font seems to look the same in both of those screenshots and in your code you don't specify a path/to/font at all so I assume that your fonts are in the same dir as your script and the font itself is shiny. Your computer has GD2 so fontsize is measured in Points (pt). Your server has GD1 so fontsize is measured in pixels (px). 8pt == 10px so you need to change $fontsize = 8; to $fontsize = 10; Quote Link to comment https://forums.phpfreaks.com/topic/208048-text-outputted-with-gd-is-pixelated-and-ugly/#findComment-1088684 Share on other sites More sharing options...
Fabis94 Posted July 20, 2010 Author Share Posted July 20, 2010 Actually the version of GD on the server is 2.0.34. AND this is really strange, but without changing anything it magically started working...so err...i guess solved? Quote Link to comment https://forums.phpfreaks.com/topic/208048-text-outputted-with-gd-is-pixelated-and-ugly/#findComment-1088696 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.