Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
OT, OT to the max: Re: Image Library Preferencesby Your Mother (Archbishop) |
on Jan 27, 2018 at 08:11 UTC ( [id://1207982]=note: print w/replies, xml ) | Need Help?? |
Update: reorganized a little. Added link to JavaScript Weekly. The webpage code below does what you ask, albeit basically and without Perl: enter text, get fancy image version dynamically, download with a click. 70 lines of "code." Half HTML, half JS. Like pryrt, I recommend GD; and png as the default output for text oriented stuff. I used GD a lot in the distant past and liked the results but was never particularly happy with coding with it or its limitations. The HTML5+JS I'm sharing is, to me, more fun and interesting. It works on Firefox and Chrome. Early test of it worked on IE11 but current code has an issue blocking the font usage. No <spoiler/> because I don't expect this thread to grow.
Two reasons I post this. One, it's really fun so I wanted to try it. I knew it was possible but I'm quite behind on this stuff. Despite some boiler plate and annoying font metrics shortcomings in canvas—which was much easier to get around than most folks on various forums seemed to think—it was really quite easy. And two, I say y'all aren't scared of the right things. ECMAScript/JavaScript has been in the process of evolving into a kickass language; improving syntax, affording asynchronous programming in ways that are increasingly easy to follow, better scoping, and plenty more. It scares me how far behind I am. It's been ubiquitous in the browser for decades now. Its serverside presence and toolchain is bigger and better every day. Perl 6 is not (yet) a real threat to Perl 5. Python and Ruby are mild threats, yes, but ES/JS has eaten ActionScript/Flash's lunch already and it's only getting hungrier; pulling in more and more smart devs who are making some incredible stuff with it. Update: JavaScript Weekly is a great resource. The current batch of articles cover new features in ECMAScript 2018 which include lookbehind and named captures in regular expressions and asynchronous iteration. I wish I had the knowledge to do a tutorial or recommend reading. As I mentioned, I'm not qualified. The stupid example above, all 35 lines of actual code, took me a couple hours, for example. Anyone who knew what she was doing could have thrown a bombproof version of the idea together in 10 minutes. What this is missing is a font loading check, a little more error guarding, a font/webfont picker, and a trim function so the image can be cropped down to the minimum dimensions matching actual content. I looked at trim-image but didn't have the patience today. The only thing Perl here is that I always do this kind of development with a command line Plack server. I can edit my HTML and do whatever without worrying about the webserver wherever I am working.
:P
In Section
Seekers of Perl Wisdom
|
|