I'd like to create a PHP image generator that takes several query string parameters and generates an image on the fly. I've done this before in ASP.NET via a handler but now I'd like to in PHP. For example, I'd like a call to image.php?img1=foo.jpg&img2=bar.jpg to render the concatenation of foo.jpg horizontally next to bar.jpg. Later on I'll do some mod_rewrite to make it something like foo_bar.jpg but that's not my concern. Are there any samples out there that do what I want or any code snippets to examine? This is actually more of a learning experience than a necessary step to build something.
Here's a sample application of it:
image.php?d=14&m=jan&y=2010
Would really be the graphic concatenation of 14.jpg + jan.jpg + 2010.jpg
And after mod_rewite it could be used like:
14_jan_2010.jpg
The PHP GD library can certainly do this. You can work out how large the image needs to be, create a blank one and then use imagecopymerge() to copy the three images into it.
I can give you some sample code if it helps.
http://www.psych0tik.net/images/sig.phps ::EDIT LINK IS BROKEN. I'll fix it shortly.
It's very simple (and doesn't do exactly what you want) but should be able to fulfill your needs with some minor hackery.
Related
I'm currently working on a personal project for decoding a text or any object in an image.
I'm using GD library for processing image. I have access to every pixel of image and its rgb color.
My question is not about coding,I'm just looking for an algorithm to decode image,or any advise for how to do that and I don't want to use any API, I want to do it by myself.
I know that php has a face detection library, but it only recognizes faces in image, and I don't know how it does that .
for start, I assume that the object is white and the background is black (or any separate colors) .
summary : How can I define an object or a word for a php program and train it to recognize it from a picture?
You have some api which decode simple captcha like this.
Check this link : Captcha Decoded
And try with this api : http://www.opendecoder.com/api, there are many API if you search on google
The process you are trying to implement is called “optical character recognition” and there is some free software available and doing this. With this expressions, you may find more information.
You did not specify the kind of software component you are looking far, so it is hard to be more specific.
This is usually an error-prone process, but you might get better results if you can make regularity assumptions on your input, especially if you already know which character types are used in your input.
Useful starting points could be
http://jwilk.net/software/ocrodjvu
http://unpaper.berlios.de/
If converting to DJVU and using python on a UNIX system is an option for you, you might consider a the first link as a solution. Otherwise you may use the various tools supported by ocrodjvu to start your research. The second is more about pre-processing you might want to do before OCR but still might be useful if you want to implement your own procedure.
I'm looking for a way to create a QR Code and a shortened link when a form is submitted. I have the QR Code bit, but the link is too long for me and the QR Code looks scary and complicated. The way it works is; the user types in (in this instance) a contract number. Then, a folder is created on the server of that contract number. (www.mysite.com/QR/$contractnumber). Then, using PHP again, I create a QR Code through Google because I know that every QR code will be linking to the same place, just a different ending of the link. The only bit that changes is the $POST...
I was wondering if there was a way to shorten the link before it goes to Google? It would have to be through php. The user enters the contact number in the form, then that number(usually around 5/6 digits) will be entered into a already existing command? I'm not an expert in anything, I just know some really random snippets of code... And HTML and CSS, of course.
Any help would be appreciated and judging by the few days I have been searching this, I think it might help a few people in the future. I would also like to confirm that the solution can't be one of this visual URLShorteners. If it is, it just needs to be the back-end of it, built into a existing form and QR Generator. Simple?
We had a similar challenge with one of our internal apps, and since any shortcut system (that I know of) relies on a database to translate what the short url really means , we opted to start our work from something that had already been done, rather than re-invent the wheel and based our solution on yourls.org.
We installed that, and populated the database from within our PHP, not really using the provided interface for anything except testing and it's statistics. It's reasonably flexible, and while it does need some standards improvement, the core code that we were interested in (as you would be) was sound, and worked very well for us.
It sounds like you might be able to use the TagLabs solution. Check out the developer site; developer.taglabsinc.com and create a free account at portal.taglabsinc.com. The platform will create the QR Code and shortened url. You can manually create the QR Codes or leverage the API.
For what it's worth, that's exactly what a.zat.is for. Disclaimer: I made it.
I want to change my HTML page as an image. Is there a way in PHP to change or save an HTML page as an image?
This is not easy; as NullUserException says in his comment, you would need to render the HTML page on the server-side, which is not something PHP (or any other server-sided language) has built in.
The approach that comes to mind would be to write a program (probably not in PHP, but rather something like C# or C++) that runs on your server, fires up a web browser, and does a series of screen captures (possibly combined with page scrolls). As this is a very nontrivial and bug-prone process, I would suggest looking into third-party components that are capable of doing this.
You would then execute this program from PHP, and when it's done running, display the results from the file it output.
I would advise you to use an external service with an api. This list might be a good start: http://blogs.sitepoint.com/2008/07/10/9-ways-to-put-site-screenshots-in-your-web-app/
Thumbalizr seems great, they allso provide a php script so you can cache the images locally:
http://www.thumbalizr.com/apitools.php
Try taking a look at browsershots.org - source code is available for it if you want to install it locally. Essentially it uses a browser to take screenshots, and can be controlled via an XML-RPC interface, which you can call from PHP.
As others have said this is not a simple job, and not something you can do directly in PHP, so use an external service.
(I'm not affiliated with browsershots.org in any way)
Pse forgive what is most likely a stupid question. I've successfully managed to follow the simplehtmldom examples and get data that I want off one webpage.
I want to be able to set the function to go through all html pages in a directory and extract the data. I've googled and googled but now I'm confused as I had in my ignorant state thought I could (in some way) use PHP to form an array of the filenames in the directory but I'm struggling with this.
Also it seems that a lot of the examples I've seen are using curl. Please can someone tell me how it should be done. THere are a significant number of files. I've tried concatenating them but this only works with doing this through an html editor - using cat -> doesn't work.
You probably want to use glob('some/directory/*.html'); (manual page) to get a list of all the files as an array. Then iterate over that and use the DOM stuff for each filename.
You only need curl if you're pulling the HTML from another web server, if these are stored on your web server you want glob().
Assuming the parser you talk about is working ok, you should build a simple www-spider. Look at all the links in a webpage and build a list of "links-to-scan". And scan each of those pages...
You should take care of circular references though.
Looking to start a project that would require me to use Flash or Flex (I have not worked with either of these yet, yikes!!!). Flash would be the front end user interface that needs to display items pulled from a MySQL Database (I was thinking ajax via jQuery but open to suggestions). My question is, What would be the best approach for something like this?
High level
Flash calls to display image through ajax/php from Db
I don't know how to code the Flash part, any tutorials that kinda sound like what I'm doing? suggestions? thoughts? other ideas?
Side Note: The database table will contain text that describes the image being passed to flash, so I would like to display both the text and image.
Thanks for any advice/help,
--Phill
I'd recommend you try AMFPHP or ZendAMF. Both of these use AMF3 (which requires you to use Actionscript 3/FlashCS3+), and it is one of the quickest ways to get data into Flash.
You could also use php to generate an xml file and just request that url in Flash to load up the XML. You can also use ajax like you said, but it's probably going to be the slowest method open to you, unless you're working with very small data sets.
Regardless of the method you choose, I'd suggest you use Actionscript 3. It's much faster and if you use XML, it'll be a life saver.
Here's a tutorial about setting up flash to work with PHP & MySQL:
link