adding text to TIFF - image-manipulation

I need to add text string to a TIFF image. I am planning to use libTIFF for editing the TIFF image. The plan is to convert text to image using freetype2 and then somehow render the text image on to TIFF. Is this the right approach?
Any pointers on how to convert text to image? I saw the sample code of ft2 - initialising the library, creating face and then setting character sizes. But not sure what to do next? any pointers appreaciated.

One way could be using ImageMagick. They have tools for image composition and text rendering. (and many more)
Although ImageMagick is primarily used from the command line (especially in web environments) several language interfaces are available, too. Java, C, C++, ...

ImgSource is a really nice library for C/C++ on Windows, and it can do this out of the box.
http://www.smalleranimals.com/isource.htm
It's not free, but it's pretty cheap ($59)

You don't tell us which language you need to use, should it be portable or for a given platform, etc.
Using a ready to use existing graphic library, like the (big!) ImageMagick or others like libGD or DevIL might be the easiest way, lot of them have binding for lot of languages.

if youre on windows and in c++ then it's pretty easy to use gdiplus for drawing fonts. you have access to any installed font and you can save the raster out as tiff or jpeg etc as well using the one api.
of course you could also use some combo of freetype and libtiff, but you'll have to build those libs for win32. not that its hard, just more fussing around you may not want to do.

Related

How to convert cgm to png on windows

I want to convert a .cgm file to an image file (.png) on windows.
Are there any freeware/opensource tools for this? I tried to ImageMagik but it does not support this operation. Commandline inteface will be an added advance if any of the tools provide it.
UniConvertor is open source, and the best choice in my opinion.
The windows binaries worked great for me, https://sk1project.net/uc2/download/
From a command line you'd simply type uniconvertor input.cgm output.png
You can try https://cortona3d.com/en/cortona2d-viewer-download. When installed it understand .cgm extension and directly opens in IE and you can view it/or take snapshot.
Other tool that you can try(but not free) is reaConverter(https://www.reaconverter.com/)
It has a nice command line interface that converts cgm to PNG directly
There is a free tool available XnView which is very handy when it comes to view, resize and edit your images. It supports more than 500 different formats. But you will have to download an additional plug-in https://www.cadsofttools.com/products/plugins-for-3d-party-programs/ It will enable your need to deal with CGM file formats.

Convert text from image into text file

I have an image and I want to convert it text file to use in word processing software. 1) Can it be done in any software. 2) Is it possible to write a program in Matlab or any other language that can convert it to text. The font is really poor in the image file.
You're talking about OCR where there are existing libraries that can be used for this. I suggest you take a look at Leadtools OCR. I used it in .NET environment and it can convert images to text.
Yes, it can be converted into text by using softwares like Microsoft OneNote or others. You can also write programmes for creating an OCR in most of the programming languages.

Illustrator add class to svg group

i have searched from hours to find a solution to export a SVG with class on the group element. Is it possible this thing?
I have found a program inkscape which can edit in XML mode and add the attribute. The problem is that inkscape insert too much garbage code to use in the web.
Can it be done in illustrator or program in which the SVG stays with clean code.
Edit - 06.12.2015
For now there is not a good program solution, the best tool to do is inkscape.
For this to work you need to use the XML ediotor in the program, so it is not very user friendly also it includes too much markup in SVG.
This is an explanation by Adobe on how to export SVG from Illustrator CC.
they don't mention classes though.
how about ID's? might be equally useful
Illustrator wraps every layer in a g element that gets his ID from the layer's name.
you could use it to construct your svg accordingly and get each group of elements with the id you want.
the latest version of AI spits pretty clean code I think.
but you could use an online tool to optimise it.

Can cairo load a PDF?

This sounds really simple, but I can't find a way to load a PDF into Cairo. I want to be able to do cairo.PDFSurface.create_from_pdf in the same way I do cairo.ImageSurface.create_from_png (yes I'm using the Python bindings but that's neither here nor there).
The documentation doesn't appear to give any hints.
No, cairo cannot read PDFs. However, poppler can load PDFs an paint them onto a cairo context - http://poppler.freedesktop.org/
(Oh and create_from_png() is part of cairo's toy API. It works, but you are recommended to use some "real" API which can do more things than just loading PNGs)

Are there any tutorials on coding a parser for SVG files to be used by box2D?

I am trying to create an iPhone game with fairly large levels. Hard coding the platforms and physics objects is very time consuming. I have seen some people have made their own parsers for svg files to use in box2D, and Riq is selling levelSVG but it is a little pricey for me at the moment, and I only need basic features. Is there a tutorial on how to code a parser available online?
Have you taken a look at SVGQuartzRenderer? It is designed to render SVG files in Quartz, so I imagine you might be able to pull out the SVG parsing code from this. It's opensource, MIT license.
I don't know about any tutorials but its fairly easy to do this using an XML parsing library. In my project I use MiniDOM to load an svg file and then I convert the elements into objects in the box2d word. The only thing that I had to do manually was the parsing of the path element.
I've written an extensive tutorial on how to parse SVG files using Apache Batik SVG library. Included with the tutorial are a set of classes and a function I wrote in Java which will generate a set of Vec2 points given the location of the SVG file. If you're using Objective C you could try to port the scripts or at least get an idea of the process involved. The scripts support multiple paths per SVG file, transformations, straight lines and quadratic splines. The first tutorial in the series can be found here.