Link to home
Start Free TrialLog in
Avatar of coerrace
coerrace

asked on

txt over a picture and converted to png

Hello suppose I have a string variable called "stringbutton" that could be in vbscript, inside the same directory will be a picture called "button.png"; now what code could be in vbscript to do that depending of the value of "stringbutton" then create a new picture in the same directory with the file name of "stringbutton" value without spaces and that new image will be, like background the "button.png" original image and over the text value of the string "stringbutton" but with full spaces here, just the spaces must be deleted on the file name but not on the picture to display.

   For example:

   stringbutton="element to discover in science"
   then the new resulting created picture in same directory will have this file name "elementtodiscoverinscience.png" and that image has like background the original "button.png" image and over the "stringbutton" value with full spaces here in other words "element to discover in science"' in resume if you click to see the image "elementtodiscoverinscience.png" you will see a picture with background of the "button.png" image mixed with an over text in that background that will say "element to discover in science"
   
   Someone could help in post a code to do?
   The code I need is to place in one html lage in the middle of:

<%

put code here

%>
   Could be used Imagemagick or any program to do.
Thank you
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

I can show you how to do this with image magick but you are better off just using css.   http://jsbin.com/tahibe/1/edit?html,output

<!DOCTYPE html>
<html>
<head>
  <style>
    .img span{

   position: absolute; 
   top: 20px; 
   left: 20px; 
   width: 100%;  
  

}
  </style>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <div class="img">
    <img src="http://placehold.it/350x150">
    <span>This is some text</span>  

</div>  
</body>
</html>

Open in new window

Avatar of coerrace
coerrace

ASKER

Ok that is ok for regular HTML but I want that result being stored automatic in a new PNG, in other words your 2 resulting elements:

    <img src="http://placehold.it/350x150">
    <span>This is some text</span>  

Stored in a new file called "elementtodiscoverinscience.png" and the source of the text comes from a source stringbutton="element to discover in science" and the file name is removeing spaces for that stringbutton variable.
   Then is needed to manipulate in other way to store in hard drive.
Thank you
Do you have imagemagick set up?  

My own experimentation with this has proven text in some cases does not come out as expected. If you can deal with using css, I think you are much better off.

http://www.imagemagick.org/Usage/text/
http://www.imagemagick.org/Usage/annotating/

Let me know if you need help converting this to vb.  If you have used imagemagick already, this should make sense.
I have installed imagemagick , but could be another thing really I don´t know how to do, but yes if possible to convert to VBSCRIPT not visual basic,  just vbscript and to store the image in hard drive like I explain in main topic if possible.
Thank you
my guess is that you want the Annotating option for IM as Scott linked to above..

as a test, let's take a blank asp page and see if we can just get the text to appear on the image, from there we can move on to incorporating it directly into your code. have a look at the code below and see if you can get it working on a test page

<%
Set Img = Server.CreateObject("ImageMagickObject.MagickImage.1")

stringbutton="element to discover in science"
strButtonFile = "<hard code a path here for testing>"
newFileName = "<hard code a path here for testing>"

 Img.Convert stringButtonFile, "-background Khaki",  label:'" & stringButton & "'", "-gravity Center", "-append",    newFileName      

%>

Open in new window


again, this is just to test writing the text where you want it, we'll worry about converting the string button text to the file name later on

**edit - missed a comma
ASKER CERTIFIED SOLUTION
Avatar of coerrace
coerrace

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Work solved in other way