How to annotate text on image files?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to annotate text on image files?
# 1  
Old 07-25-2012
How to annotate text on image files?

Dear Sir,
The problem description as follows
I have a folder named abc with files of different extensions such as:
Code:
bcsu.txt
hsdk.prot
ajia.sh
sai.hm
abcd_1213_saj.png

I am supposed to write a bash script which reads all the .png files
and read the 6th7th8th9th(word/numerals) here it is 1213
and add it on the bottom of the same image file.So that when we open the image file
abcd_1213_saj.png , we could see the 1213 on the bottom line
This script should read all the png files in the defined folder do the same task.

Last edited by methyl; 07-25-2012 at 08:09 AM.. Reason: please use code tags
# 2  
Old 07-25-2012
Please tell us about .png files . Are they a simple text format suitable for processing in Shell Tools or some other format which needs special programming?

Last edited by methyl; 07-25-2012 at 08:21 AM..
# 3  
Old 07-25-2012
a simple text format is enough....no special effects or programming is required
# 4  
Old 07-25-2012
In that case it can't be Portable Network Graphics format (a format which is unsuitable for editing with test-based tools).


You probably need a script someting like this:

Code:
#!/bin/bash
cd abc
ls -1d *\.png | while read filename
do
      # make sure it is a proper file
      if [ -f "${filename}" ]
      then
           numerals=$(echo ${filename}|cut -c6-9)
           # For testing, work on a copy of each file
           # Copy the file
           cp -p "${filename}" "${filename}.sav"
           # Append the text 
           echo "${numerals}" >> "${filename.sav}"
     fi
done


Last edited by methyl; 07-26-2012 at 06:35 PM..
# 5  
Old 07-26-2012
its not reading the 6th to 9th numerals......

---------- Post updated 07-26-12 at 03:08 AM ---------- Previous update was 07-25-12 at 11:53 PM ----------

Code:
#!/bin/bash
FILES=/home/balnair/transfer/Images/test/*
for f in $FILES
do
  echo "Processing $f file....."
 
         numerals=$(echo ${f}|cut -c56-59)
  
  
        echo "$numerals" 
  
 
convert $FILES -font courier -fill white -pointsize 20 -annotate +50+50 '$numerals'  $numerals.jpg

done



There are some issues facing in the above script


1.script could able to get the numeras , but unable to annotate on the image
2.multiple files are being wriiten for a particular png files

what could be done?...wht shoud be the modification in this script?


Thanks in advance
Moderator's Comments:
Mod Comment Code tags for code, please.

Last edited by Corona688; 07-26-2012 at 12:05 PM..
# 6  
Old 07-26-2012
Quote:
Originally Posted by bal_nair
1.script could able to get the numeras , but unable to annotate on the image
I'm not sure what you mean.
Quote:
2.multiple files are being wriiten for a particular png files
Could you give an example of what's happening?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Web Development

Center image between two text paragraphs.

I want to show a page with an image between 2 any paragraphs. I tried the following script. But the image is not centered. SUSE Paste <!DOCTYPE html> <html> <head> <style> center.center_1 { margin: auto; width: 60%; ... (3 Replies)
Discussion started by: jcdole
3 Replies

2. Shell Programming and Scripting

Script to convert text to image

Hi Can someone help me writing a script to convert the texts in a text file into images for each token? Thanks in advance. :) (1 Reply)
Discussion started by: my_Perl
1 Replies

3. Shell Programming and Scripting

Perl script to extract text from image file

Hi Folks, Could you please share your ideas on extracting text from image file(jpg,png and gif formats). Regards, J (1 Reply)
Discussion started by: scriptscript
1 Replies

4. Shell Programming and Scripting

matching image files to create one image

Hi, I have two sets of image files. Both sets have names A to Z but set 1 ends with .cdt.png and set 2 ends with .matrix.png. I want set 1 to match with set 2 if the names match (i.e. A.cdt.png will match with A.matrix.png) and with the convert image tool (program for images), it will merge the... (6 Replies)
Discussion started by: kylle345
6 Replies

5. Shell Programming and Scripting

Add text to image files

Hi to all, Some help here please. I have a several image files (photos, jpg files), let say 100 photos, and a list of 100 different little comments in a text file, each comment for each image. Somebody knows if I can add (like a watermark in the bottom) this text comments and how in the... (3 Replies)
Discussion started by: cgkmal
3 Replies

6. Shell Programming and Scripting

Send mail with rich text / HTML with image

Hi, Is it possible to send mail from my HP-Ux system with images, rich text? I would like to program in such a way that I have my company's logo(.jpg) image attached in the mail geeting triggered. I would like to send a rich text/HTML email instead of plain text mail to the recipients. Is it... (2 Replies)
Discussion started by: rythym05
2 Replies

7. Shell Programming and Scripting

Redirect text to image file

How can I redirect text data to an image (png, jpg, gif... etc) file using perl on unix solaris environment?? Please suggest. Pooja (1 Reply)
Discussion started by: wadhwa.pooja
1 Replies

8. UNIX for Advanced & Expert Users

Create an Ignite image on tape from Online IgniteUX image

Hi, (HP-UX 11.11) I need to create a tape image of an igniteUX image created on our igniteUX server. That is to say. I have a "Online" image of the igniteUX of the targeted system but I now need to copy it to a useable TAPE (igniteUX) image so i can build an other server from it that is not... (3 Replies)
Discussion started by: Andrek
3 Replies

9. Windows & DOS: Issues & Discussions

Unix text doc with a .gif image

I would like to insert a .gif image into a text file that is generated by a Unix-based database application. Can anyone please tell me how I can achieve this? (7 Replies)
Discussion started by: sunita_rao
7 Replies

10. Shell Programming and Scripting

Stamping Text on an Image File

Hi all, again, I have lots of questions I guess. This one should be easier though :) . I have a goal to be able to put some preformatted text into a template (which is now a tiff file, but can be changed) and then output it to a printer. Right now we're thinking PostScript might work or some... (0 Replies)
Discussion started by: pageld
0 Replies
Login or Register to Ask a Question