I have got an image file which has 3 colors as background. I have also got a text file . I need to write a Perl script which copies text file on to the specific background color of the image file.
When I execute my Perl script , the script should ask the path for image file and then the path for text file.
This sounds like a job for ImageMagick, this page has some examples that should help you get started.
I use GD for this sort of work. Image::Magick will also do the trick.
Related
I am running tesseract on windows 11 using the command prompt.
The text file is my training data. Words that I want to turn into images.
The output is the next step in the Tesseract process for training my font.
I am saying find fonts but I only have one font in the folder.
text2image --text="C:\PythonProjects\DiabloTesseractTrainFont\text.txt" --outputbase="C:\PythonProjects\DiabloTesseractTrainFont\Output\Dia.font.exp0" --fontconfig_tmpdir="C:\PythonProjects\DiabloTesseractTrainFont" --find_fonts --fonts_dir="C:\PythonProjects\DiabloTesseractTrainFont\Diablo Fonts"
The result:
Total chars = 223645
Font Exocet Light failed with 223518 hits = 99.94%
Not sure why it fails. I have built something similar to this before. I have tried with a font file that I know has worked and it does the exact same thing.
Any help would be appreciated.
I solved it. In the text file, there were some characters that had been changed when I read them into python. I believe they used to be bullet points but when I read the file I had implemented in python ASCII encoding and ignore errors. I figured that those characters would be removed. I was wrong. Those bullet points were replaced with text that said PAD. I found it in notepad++ and highlighted one of them and then replaced them with a space. Note in Notepad++ when I did the replace it did not have anything in the find field but it still replaced all of them. Now it compiles just fine. I was stuck for many hours I hope this helps someone.
I've been trying to make the output shown in the text file instead of the command window. Im blur right now as i already look at a lot of example but it always show the error on fprintf. I try to edit the code of fprintf(fid,'%s\n',word);%Write 'word' in text file (upper) in one of the Matlab example which is Automatically Detect and Recognize Text in Natural Images.
This is the link of the code.
https://www.mathworks.com/help/vision/examples/automatically-detect-and-recognize-text-in-natural-images.html?s_tid=srchtitle
Basically the above link display the output on the command window. But, i need it to be on the txt file.
Im really new to this, i want to know what code do i need to put, how and where should i put the fprintf to make the output shown on the text file and not on the command window.
Also, can i save the text file after that? do i to put any additional code?
I really need your help. Thank u in advance!
It seems you're looking for the fopen() method. It takes two parameters, the first being the name of the file you'd like to write to, and the second being the mode. If the file specified does not exist in the root directory, it will be created on execution.
fileID = fopen('exp.txt','w');
fprintf(fileID, fid,'%s\n', word);
fclose(fileID); % Make sure to always close the stream after finishing
More on fopen() here
I am running below script to create images from postscript file, the images are coming but on first page watermark is not there.
gs -dUseCIEColor -dNOPAUSE -sDEVICE=jpeg -dFirstPage="1" -dLastPage=2 -sOutputFile=outputImage_%0d_A.gif -dJPEGQ=100 -r300 -q inputFile.ps -c quit;'
I am giving the link of ps file which i am using.
http://speedy.sh/Y7vWj/inputFile.ps
Can anybody please help!!!!
Thanks in advance...
OK you haven't stated what version of Ghostscript you are using, nor have you been very clear about what is missing. By 'watermak' do you mean the dark grey text 'PAULDAVIS' written diagonally across the very dark grey rectangle ?
If so then I can see that using the current version of Ghostscript and your command line, its not missing
A few observations on your command line:
-dUseCIEColor - Don't use this unless you know exactly what you are doing and why you want this, I'm guessing you don't (because you have not set any Color Rendering Dictionary). With this you get very dark grey text which is nearly invisible against the very dark grey rectangle. Not surprising since this relates to colour management.
You've set the device to jpeg, but you've set the output file to have a .gif extension.
You are using -dFirstPage and -dLastPage which have no effect when the input is not PDF (though this is added as a new feature in unreleased code).
You've set FirstPage=1 and LastPage=2 on a 2 page file.....
You have set -dFirstPage="1", which isn't going to work for any code which parses and uses it. The quotes won't work.
I'd recommend you do not set -q or -dQUIET when trying to diagnose problems, telling Ghostscript to be quiet will potentially mean you miss useful information.
-c quit; -c means 'process the next part of the command line as PostScript'. But quit; isn't valid PostScript (the semicolon should not be present) and will throw a PostScript error. If you want GS to exit after processing, consider simply using -dBATCH.
I have an .svg file with only one color. I want to change this color to another and export it through command line. (I have to do it about 100 times, so doing it by hand doesn't work.) I use Inkscape at the moment.
I am able to change the background color and export with this command:
inkscape -f name.svt -e output_name.png -b #000080
But I cannot find the way to change the normal color.
I find this verb:
org.inkscape.color.replacecolor
But I don't know, how to add the color I want to use, somewhere I read, that I cannot add variables to verbes, but in that case how can be this verb used?
Thank you in advance.
This is not a general purpose solution, but since a SVG file is just XML internally, if your SVG file is simple enough you might be able to get away with a simple sed replacement. For example the following replaces #000000 (black) with #ffffff (white):
sed -e "s/#000000/#ffffff/" input.svg >output.svg
This may or may not be good enough for your needs.
Although inkscape is a powerful tool, I think you will have more luck (control) with xlst tranformations. This will allow you to do anything to an xml file rather than parsing the file as an svg image and relying on the available API. You might take a look at a tool like xsltproc for this.
#!/usr/local/bin/perl
use warnings;
use strict;
use CGI qw(:standard);
print header;
print start_html(-title=>"Hello World",
-bgcolor=>"#cccccc", -text=>"#999999",
-background=>"healo.jpg");
The color displays, but not the image.
I have the healo.jpg located in the bin folder and my home folder.
I took this code from http://www.cgi101.com/book/ch1/text.html
Please help.
If your CGI script is in a standard cgi-bin, the file healo.jpg cannot be stored there because it is not a CGI script. Try putting it somewhere else.
For example, you could put the image file in your wwwroot, so that you can find it at http://csvlife.com/healo.jpg (there's already something there), and then change that part of the code to -background=>"/healo.jpg".
Examine your generated HTML. That's going to generate a background attribute of the form:
background = 'healo.jpg'
This means healo.jpg needs to be in the same directory as wherever you currently are, which is likely not the same as your home folder.
You'll either need to copy the image to the webroot (which you likely can't do), or change the argument to start_html to be an absolute path, e.g. background ='/healo.jpg'