Log in

View Full Version : Paint with program... possible?



auriaks
02-19-2010, 03:25 PM
Hi,

I have blue picture and want to write a word on it... It is possible to do that with php or javaScript?

Picture is image.jpg
variable with word value: $word

Thanks for your time :)

djr33
02-19-2010, 06:21 PM
Using PHP's gd library, you can add a string of text to an image, but this requires using an existing font or adding a font to your server and using that.
I don't know what you mean about "painting"-- if you are ok with "normal" text, that's fine. If you want it to actually look like a drawing, then that means you need to find a font that looks good.
If it needs to be animated, you could TRY Javascript, but there aren't many options. Flash is probably what you need to use.


Here is a very interesting script:
http://www.vicsjavascripts.org.uk/SketchPad/SketchPad.htm

The only problem is that you have to draw it and then save it. It cannot be generated automatically (from "$text").

auriaks
02-20-2010, 02:51 PM
All I want to do is:

to place symbols in the chosen position on the white background...

if it is confusing I can try to explain in other way?

auriaks
02-20-2010, 03:04 PM
As example I have:

20x
13
---
and picture ubtitled2.jpg

Can script add them together like in my uploaded intitled.jpg??

djr33
02-21-2010, 12:34 AM
PHP's GD image library functions can do a lot of things, including that, in several ways. They can write a string of text to an image (and you can do this twice for the two values) or they can combine two images.
However, the functions are very hard to work with and will often be very slow to process.
It's possible, yes. It's best to pre-process everything, if you don't need it to change a lot.
For example, when using it to save thumbnails of images, it's best to run all of the images through once, save the thumbnails then not process each time every user loads the page. If the values change each page load, then there's no way around that-- but it will be slow and might cause processing load problems on the server.

The GD library is difficult, so if you need help writing a specific script, I'd suggest looking for paid help. If you get most of the script done someone may be able to help fix a few things, but working with it is never fun and usually very time consuming. Just a warning.

auriaks
02-21-2010, 05:59 AM
thanks, I think i will stop searching for that thing...

Maybe you have some ideas how to upload multiple files with comment, then? Because user can add many images/files or just one and that is difficult for me to create. How will yhe program know how many uploads user inserts?

djr33
02-21-2010, 06:37 AM
That's a complex question. The easiest way is to do one image (and comment) per upload. Just repeat as many times as they would like.
You could try to dynamically generate fields with Javascript then parse them all with PHP, but that gets very messy.
I don't know of an existing script that does this, because it's so system-integrated-- it would be hard to make a "plug and play" script of any kind that would work.

auriaks
02-21-2010, 06:48 AM
OK... Thanks.