Using ImageMagick from Command line in .Net? - image-processing

I am using ImageMagick from Commandline in .Net? Although a .Net wrapper (ImageMagick.Net in codeplex) is available but it is still in alpha and does not have implementation for all the command line options e.g Distort, Montage. Therefore I am using System.Diagnostics.Process class to invoke the ImageMagick command line.
What are the Pros/Con of this approach? I can see a performance issue if I have to perform multiple transformation on the same image and if I invoke the command twice then the commandline will load the Image twice. Is there a way I can chain the commands so that output of the first transformation is feed into the second command?

It will definitely be slower, and when you chain commands, you are going to be encoding and decoding the image into a format unnecessarily -- if you do this, make sure you use a lossless format like PNG for intermediate formats. To speed it up, use one without compression.
Two other choices
Use ImageMagick.NET and then wrap anything else you need from imagemagick yourself, probably by contributing to the project
My company, Atalasoft, has a free .NET imaging SDK with a lot of overlap with ImageMagick. You can download here: http://atalasoft.com/photofree -- Montage is basically the same as our Overlay commands and Distort is a 2D transformation, which are all included. If ImageMagick.NET can accept and produce .NET Bitmap objects, then you can use both together fairly easily.

Related

Start and pipe to process such as gnuplot in F# interactive

Essentially I want start a gnuplot process from within a .fsx script and pipe text commands to it so I can have my script replot. So far I have just been piping the stdout using the command line like this.
fsharpi "something.fsx" | gnuplot
I am doing this instead of using a plotting library because I am using gnuplot for other plots and I want the style to be the same. Also it's nice to have a lightweight solution. I am using mono on arch linux.
How can I start a gnuplot process from within a .fsx script and create a stream which allows me to pipe commands to it?
I hope that was enough detail. Thank you :)
There is actually a semi-abandoned F# wrapper for gnuplot called FnuPlot.
The library aimed to build a nice F#-friendly DSL for constructing GnuPlot charts, but it is very incomplete and does not cover very many of the charts and features you can use with GnuPlot.
However, it also implements some core functionality for calling GnuPlot, including starting GnuPlot, sending data to it and formatting various parameters. So, even if you cannot use the library directly, you can explore the code and use some bits of the code from there. For example here is how it starts the gnuplot process and here is how to send data to gnuplot. Of course, it would be even better if you wanted to contribute and help develop and maintain the library further :-).

Convert JPG,GIF,EPS and PDF to PDF with Imagemagick in PHP

I need to convert jpg,gif and eps files to pdf and vice versa. Is ImageMagick will be the best tool for this ? I have configure imagemagic with ubuntu 11.04 and using CLI trying to convert images into pdf, but quality is too bad. So what whoud be best approch to convertion ?
Thanks in Advance :)
You want to support two types of files; raster (jpg/gif) and vectorial (eps). Conversion from one set to the other is never lossless.
When converting from vectorial to raster or vice-versa, one crucial parameter is -density, that sets the image size before it gets converted.
Imagemagick is probably the right tool for vectorial to raster, it's just a matter of getting the parameters right. To transform raster to vectorial, better tools would probably be autotrace or potrace, but be aware these tools cannot do a perfect conversion.

Creating DDS(DXT5) from two files (RGB+Alpha). Command line tool need

I need some command-line tool to create dds (dxt5 format) from two .png files -- one with rgb channels and one with alpha. It's because I have a waste amount of images to process -- I can't do it manually. It's no problem for me to create script for generating batch file to process all images one by one, but I need tool to create dds from two png-s.
Anyone known such command-line tool ?
Thanks.
P.S. nvDXT.exe is very good but it can't combine rgb and alpha from different files.
If you have Photoshop, you could always use Batch Script (see Batch Scripting Tutorial for an example) to merge the channels (with NVidea plug in installed, you could probably even do the DDS conversion too). Just a thought.

Tool for batch processing EPS to JPG

Does anyone know of a adobe command line tool for creating jpegs from pdfs. This needs to cater for EPS 15 ( CS5 )?
I am converting EPS files to hi-res JPEGS with imagemagic but the results are mediocre even when the EPS is scanned at a very high-res. I think imagemagic works off the eps preview rather than rasterizing the vector.
GIMP is a bit better but not perfect.
Photoshop produces perfect jpegs but I dont know of a command line utility for this and have used the scripting tools but found them a pain on large batches.
I have distiller server but this ( to my knowledge ) does not produce jpegs.
You could try ghostscript:
gs -sDEVICE=ppmraw -sOutputFile=file%d.ppm -r600 -dNOPAUSE yourfile.ps -c quit
I would give GraphicsMagick http://www.graphicsmagick.org a try. It's a fork of Image Magick, more complete and updated.
It internally uses GhostScript as the PS interpreter, it does not use the embedded image but it completely renders the postscript.
For best results, make sure that you work at the right density. Instead of the PostScript standard of 72 DPI, try
gm convert -density 144 infile.eps outfile.jpg
with different -density values and see if the quality improves.
If you're out of luck to find a command line tool for this, you can create a macro to script GIMP or Photoshop to do the job.
You have not mentioned the operating system, but if you're using OS X you can write an AppleScript which will do the converting through commanding the GUI programs.
In Windows you can download a macro recorder program, but I have no experience with that in the new versions of Windows.
http://www.reaconverter.com/command-line-image-processing.html for 50USD
Inkscape is a mature free vector graphics program with commandline import/export options. I would be happy to test its ability to handle EPS15 but I don't have CS5 or any documents in that format. If you can post a link I'll try it out.
http://www.adobe.com/eeurope/products/indesignserver.html does the Job.

How to translate ImageMagick commands into ImageMagick API calls?

I need to do some light image processing on large image, and I try to use ImageMagick for that. Unfortunately, the API documentation has a very low information content, with documentation similar to:
MagickDeleteImageArtifact
MagickDeleteImageArtifact() deletes a wand artifact.
The format of the MagickDeleteImageArtifact method is:
MagickBooleanType MagickDeleteImageArtifact(MagickWand *wand, const char *artifact)
A description of each parameter follows:
image
the image.
artifact
the image artifact.
Could anybody suggest a few information sources for ImageMagick that would have, you know, information?
(and yes, this piece of "documentation" is pasted from ImageMagick web site, with the incorrect parameter)
Edit: Here is the context: I develop an iOS application, so I want to call ImageMagick from the C language (or Objective-C or C++). The need is to split large images that would not fit in the limited amount of RAM of an iOS device into smaller "tiles" (and downsample for lower resolution versions too. But once I have the tiles, I can do that using only iOS facilities).
Edit 2: Using the command line, I can achieve this tiling with the "convert" command with corresponding parameters. So my immediate need would be to translate such a command line command into the relevant set of API calls.

Resources