writing text on selected image in website

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Leo7
Posts: 4
Joined: 2015-04-12T02:49:29-07:00
Authentication code: 6789

writing text on selected image in website

Post by Leo7 »

Hello people,

I want to do a website page you may see following:
Image

As you can see in the image, the generated text has got different font (DecoTech) and the text-color is white.

I have read some topics in forum but couldnt find how to do this in website platform. Can I do this in my website with using imagemagick? If so can someone show me the some example?

Thank you.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: writing text on selected image in website

Post by Bonzo »

I have quite a few php and Imagemagick examples on my website and this one has most of what you want except the user is uploading the image as well as the text: http://www.rubblewebs.co.uk/imagemagick ... t_form.php

BUT this is some old and basic code and would need more security and user input verification.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: writing text on selected image in website

Post by fmw42 »

Imagemagick will write the selected text to whatever image is selected. But it cannot do the web viewing and selecting from menus. That will require PHP. The appropriate imagemagick command to do the writing of text can be done using PHP exec(). See Bonzo's web site for numerous examples of PHP and Imagemagick
Leo7
Posts: 4
Joined: 2015-04-12T02:49:29-07:00
Authentication code: 6789

Re: writing text on selected image in website

Post by Leo7 »

I used the code in this page : http://www.rubblewebs.co.uk/imagemagick ... t_form.php (Thank you so much)

Actually it worked. It generates a new image with same name of image file also it writes a text I want to write on. But I can not change the font type and can not set the coordinates.

After I click to submit button it gives me this error:

Array ( [0] => convert.exe: unable to open image `rgba\(0,0,0,0.4\)': No such file or directory @ error/blob.c/OpenBlob/2617. [1] => convert.exe: no decode delegate for this image format `rgba\(0,0,0,0.4\)' @ error/constitute.c/ReadImage/544. [2] => convert.exe: unable to read font `arial.ttf' @ warning/annotate.c/RenderType/871. )
There were some errors during the Imagemagick conversion:


1


Can anyone help me?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: writing text on selected image in website

Post by Bonzo »

You need the font you are going to use in the same folder as the code. If the arial font is built into your version of Imagemagick you would just need Arial or what ever your font is called.
Are you on a Windows or Linux server? If Windows use -fill rgba(0,0,0,0.4) instead of -fill rgba\(0,0,0,0.4\)
Leo7
Posts: 4
Joined: 2015-04-12T02:49:29-07:00
Authentication code: 6789

Re: writing text on selected image in website

Post by Leo7 »

Thank you so much Bonzo! now it works perfect : )
I am using windows.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: writing text on selected image in website

Post by Bonzo »

That's good Leo7; there are some differences between Windows and Linux usage: http://www.imagemagick.org/Usage/windows/
Post Reply