ImageMagick: Convert selective images to Multipage PDF without using external text file? - imagemagick

Let's say I have a directory with 5 TIFF files in it and I want to convert some of them to a multipage PDF, but that there are other TIFS in the same directory that I do not want in the same PDF.
In other words, I want to convert file1.TIF, file2.TIF, file3.TIF --> foo.pdf, but I want to ignore file4.TIF and file5.TIF located in the same folder.
It would seem from the documentation that the only way to do this is to provide ImageMagick with a text file listing out the files and then point to it when calling the program, as in:
convert #FilesToConvert.txt C:\foo3.pdf
Is there no way to make the call inline though, so that I don't have to create a separate text file for each conversion?
Thanks in advance!

You should be able to use:
convert file1.TIF file2.TIF file3.TIF foo.pdf

Related

Brachiograph and Turtle

I am currently in the process of building a Brachiograph plotter. I am 75 years old and have a minor disability with my hands. I would like to find out if anybody can tell me how I can output Turtle Graphics to a file that can be read by the Brachiograph plotter. I believe that the linedraw.py converts a .svg to a .json file that is read by the Brachiograph. I would like to create some fractal image files and print them with the Brachiograph.
Thank you for any help that you can offer with this project.
Dick Burkhartzmeyer
Welcome to Stackoverflow. In your OP you state "I believe that the linedraw.py converts a .svg to a .json file[...]". Looking at the documentation it looks like linedraw.py will convert a bitmap to an svg file and a json file.
From the documentation:
The main use you will have for linedraw is to take a bitmap image file
as input, and save the vectorised version as:
an SVG file, to check it
a JSON file, to draw with the BrachioGraph.
The way I would approach this is to create an svg with Turtle and then in your Python script convert that to a png. Then linedraw.py can be used to convert that to your JSON BrachioGraph file. I found a solution to do that in another SO thread. The answer in that thread is using Cairosvg to convert the SVG to PNG format.

Writing simple text pdf file using delphi synpdf

I want to write simple text pdf file and I use Synopse pdf Delphi library.
Is it possible to write one text line to file and it automatically insert new line to file without using coordinates?
The easiest is to use the mORMotReport.pas unit.
It is very easy to add some text, with automatic insert of lines, and page layout.
See this sample folder as reference.

how to convert a DocumentFormat.OpenXml.Presentation.shape into a HTML SVG element

I need a sample code for converting DocumentFormat.OpenXml.Presentation.shape into a HTML SVG element in .net. Please help me for this.
Thanks in advance.
RagesH.
If the presentation has shapes stored as a WMF image, then you can pass the images as a file or stream and convert it to SVG format. There are tools to convert WMF2SVG.
Refer this page.
This is for Java https://code.google.com/p/wmf2svg/
For using it with .NET, you have to convert this Jar into DLL and use it.
For Converting Jar into DLL refer this https://code.google.com/p/jar2ikvmc/
This works for me.
Hope this helps!

Convert favicon.ico to png to using ImageMagick Procedurally

It looks like ImageMagick does not always convert a single favicon.ico file to a predictable single png file - for some favicon's, it generates a bunch of other favicon-01.png, favicon-02.png, etc... Is there a way to figure out which one's the actual converted favicon you want - or figure out how many got generated, to delete the unwanted ones?
I came across with the same problem while I was trying to convert blogger's favicon and I solved it by using -flatten parameter of Imagemagick like this:
convert "favicon.ico" -thumbnail 16x16 -alpha on -background none -flatten "favicon.png"
This likely happens because there are multiple images in the icon file - this is to provide differet resolutions for different contexts. Presumably you'd want to run a search in the target directory for favicon*.png, then check the dimensions of each one to find the one you wanted (deleting the others as you go).
I guess some of these are animated gifs. You can take the first one as described here:
http://www.imagemagick.org/script/command-line-processing.php
i.e.:
$magick> convert 'images.gif[0]' image.png
I don't have ImageMagic installed, but you might try the above for all favicon.ico, it might work fine.
Otherwise, you would probably need to write a script to check for favicon-01.png and, if it exists, rename it to favicon.png and delete favicon-*.png (provided you don't have anything else named like that in the working folder).

How to convert PDF files to images using RMagick and Ruby

I'd like to take a PDF file and convert it to images, each PDF page becoming a separate image.
"Convert a .doc or .pdf to an image and display a thumbnail in Ruby?" is a similar post, but it doesn't cover how to make separate images for each page.
Using RMagick itself, you can create images for different pages:
require 'RMagick'
pdf_file_name = "test.pdf"
im = Magick::Image.read(pdf_file_name)
The code above will give you an array arr[], which will have one entry for corresponding pages. Do this if you want to generate a JPEG image of the fifth page:
im[4].write(pdf_file_name + ".jpg")
But this will load the entire PDF, so it can be slow.
Alternatively, if you want to create an image of the fifth page and don't want to load the complete PDF file:
require 'RMagick'
pdf_file_name = "test.pdf[5]"
im = Magick::Image.read(pdf_file_name)
im[0].write(pdf_file_name + ".jpg")
ImageMagick can do that with PDFs. Presumably RMagick can do it too, but I'm not familiar with it.
The code from the post you linked to:
require 'RMagick'
pdf = Magick::ImageList.new("doc.pdf")
pdf is an ImageList object, which according to the documentation delegates many of its methods to Array. You should be able to iterate over pdf and call write to write the individual images to files.
Since I can't find a way to deal with PDFs on a per-page basis in RMagick, I'd recommend first splitting the PDF into pages with pdftk's burst command, then dealing with the individual pages in RMagick. This is probably less performant than an all-in-one solution, but unfortunately no all-in-one solution presents itself.
There's also PDF::Toolkit for Ruby that hooks into pdftk but I've never used it.

Resources