3 ms·
Fit text of any length into image of fixed dimensions
- kijin 14y ago> $command = 'convert -page +5+5 -background "#'.$bgcolor.'" -fill "#000000" -font '.$font.' -size 310x680 caption:"'.$text.'" -page +0+695 -background "#000000" -fill "#000000" -size 320x60 caption:"-" -page +3+708 -background "#000000" -fill "#FFFFFF" -font '.$font.' -size 310x44 caption:"www.CORRELATED.org /'.$blog_id.'" -background "#'.$bgcolor.'" -layers mosaic pinterest_'.$blog_id.'.jpg There should be a whole bunch of escapeshellarg() in there. Who knows what the text contains? Code like this is exactly why PHP devs get a bad rep. Please don't post PHP code online unless you've made it reasonably secure, because somebody somewhere is going to copy that and get pwned. Also, why not use PHP's own imagick extension? It exposes a neat object-oriented interface, it will be much easier for people to read and tweak, and you won't have to escape anything.
- Drbble 14y agoThe author of the script might know, since he is creating the text. But it's easy to imagine that some of his fortune messages have quote marks.
- shabble 14y agoThe article/blog author does have a disclaimer at: http://coding.pressbin.com/61/Caveat-coder-About-the-code-snippets-on-this-blog/ http://coding.pressbin.com/61/Caveat-coder-About-the-code-sn... but I fear that those most likely to just grab this code and run with it, are the least likely to even notice that page, let alone heed its (nonspecific) advice.
- kijin 14y agoYou're right, a 17-month-old disclaimer is useless unless there's a link to it within a hundred pixels or so of the actual code sample. If I ever start a technical blog, I'm going to style the <code> element so that every code sample automatically gets a link to a disclaimer about security, copyright, etc. Also throw in class="insecure" (background-color: reddish) to any sample which I know should never be used in production.
- tylermenezes 14y agoIt's interesting: fitting text like this is one of those problems which I've found beginner programmers often struggle with when they come up against it. It really doesn't seem like it should be as hard as it is. Latin characters - go figure.