Tag Info

33

You can use the mogrify command for this. Normally, it modifies files in-place, but when converting formats, it writes a new file (just changing the extension to match the new format). Thus: mogrify -format pdf -- *.jpg (Like enzotib's ./*.jpg, the -- prevents any strange filenames from being interpreted as switches. Most commands recognize -- to mean ...

32

In bash: for f in *.jpg; do convert ./"$f" ./"${f%.jpg}.pdf" done

29

Here's a small Python script using the PyPdf library that does the job neatly. Save it in a script called un2up (or whatever you like), make it executable (chmod +x un2up), and run it as a filter (un2up <2up.pdf >1up.pdf). #!/usr/bin/env python import copy, sys from pyPdf import PdfFileWriter, PdfFileReader input = PdfFileReader(sys.stdin) output = ...

29

Last time I used convert for such a task I explicitly specified the size of the destination via resizing: $convert a.png b.png -compress jpeg -resize 1240x1753 \ -units PixelsPerInch -density 150x150 multipage.pdf Where 1240x1753 are exactly DIN A4 when 150 DPI is chosen. I computed the values using bc and looked up the dimensions ... 26 It's not clear what you mean by "quality loss". That could mean a lot of different things. Could you post some samples to illustrate? Perhaps cut the same section out of the poor quality and good quality versions (as a PNG to avoid further quality loss). Perhaps you need to use -density to do the conversion at a higher dpi: convert -density 300 file.pdf ... 16 take a look at this: http://askubuntu.com/questions/107726/how-to-create-animated-gif-images-of-a-screencast/107735#107735 ..... After the Desktop Recorder has saved the recording into an OGV video, MPlayer will be used to capture JPEG screenshots, saving them into the 'output' directory. On a terminal: mplayer -ao null <video file name> -vo ... 12 xxd -b (source) 12 What you really want to use is:$ convert a.png b.png -compress jpeg -resize 1240x1753 \ -extent 1240x1753 -gravity center \ -units PixelsPerInch -density 150x150 multipage.pdf -extent actually extends the image to be 1240x1753, while -resize keeps the image's ratio, fitting it into either 1240x... or ...x1753. ...

12

OpenOffice comes with the unoconv program to perform format conversions on the command line. unoconv -f csv filename.xlsx For more complex requirements, you can parse XLSX files with Spreadsheet::XLSX in Perl or openpyxl in Python. For example, here's a quickie script to print out a worksheet as a semicolon-separated CSV file (warning: untested, typed ...

11

faster and less painful syntax: parallel convert '{} {.}.pdf' ::: *.jpg Runs in parallel (using https://www.gnu.org/software/parallel/).

11

Use the convert command from ImageMagick: convert x.png -resize 25% x.jpg will create a 25%-scaled JPEG version of x.png. To do all the PNG files at once, use a for loop: for filename in *.png ; do convert "$filename" -resize 25% "${filename%.png}.jpg" ; done We look at every file matching *.png, and for each one run the convert command above. ...

10

The fundamental tool for sound format conversions and simple transformations is SoX, the Swiss Army knife of sound processing programs. sox foo.mp3 foo.flag If you're running Debian, support for writing MP3 in sox is broken in lenny and squeeze (and as far as I know the same problem affects Ubuntu 10.04 and 10.10). This bug was fixed in early March 2011, ...

10

pandoc can do this. It's more focused on converting marked-up text to various formats, but it should have no problems with simple plaintext. pandoc input.txt -o output.pdf

10

Here is a way that combines the best of the above suggestions into a simple, efficient, robust command line: find /path/to/files -iname '*.jpg' -exec mogrify -format pdf {} + It works fine with filenames that begin with a - or contain spaces. Note the use of -iname which is the case-insensitive version of -name so it will work on .JPG just as well as ...

10

One way is to use pdflatex instead of convert. You need in a extra file, which is here called image.tex: \documentclass{article} \usepackage[active,tightpage]{preview} \usepackage{graphicx} \PreviewMacro[{*[][]{}}]{\includegraphics} \begin{document} \includegraphics{img.jpg} \end{document} Then run pdflatex image.tex to generate image.pdf.

10

(adapted from comments above) Depending on the codecs used (some codecs are incompatible with some containers), you could always simply copy the streams (-codec copy). That is the best way to avoid quality changes, as you're not reencoding the streams, just repackaging those in a different container. When dealing with audio/video files, it is important to ...

9

Imagemagick can do it in one step: $convert in.pdf -crop 50%x0 +repage out.pdf 9 One method is to use CUPS and the PDF psuedo-printer to "print" the text to a PDF file. Another is to use enscript to encode to postscript and then convert from postscript to PDF using the ps2pdf file from ghostscript package. 9 LibreOffice / OpenOffice as well as most other word processors (Abiword) can do this quite easily. There is a little utility called unoconv that uses the LibreOffice code base to do file format conversions on the command line. It can read and write any combination of formats that LibreOffice can and makes it very easy to do things like doc to pdf ... 9 convert is a handy command line tool to do that. cd to the folder containing your png-files and run this command: convert -delay 10 -loop 0 *.png animation.gif Source: http://ubuntuforums.org/showthread.php?t=1132058 8 You may also try to use ffmpeg to create a movie out of a sequence of images and then convert the movie to a GIF animation (again using ffmpeg). # cf. http://pages.uoregon.edu/noeckel/MakeMovie.html # first convert an image sequence to a movie ffmpeg -sameq -i %03d.jpg output.mp4 # ... and then convert the movie to a GIF animation ffmpeg -i output.mp4 ... 8 Ok, first things first... ffmpeg's sameq option doesn't mean same quality, and in many cases will not do anything relevant. This is from the ffmpeg man page: -sameq Use same quantizer as source (implies VBR). This is actually from the ffmpeg online documentation ‘-same_quant’ Use same quantizer as source (implies VBR). Note that this is NOT ... 8 potrace I found this example on SO in a Q&A titled: How to convert a JPEG image into SVG format using ImageMagick?. One of the answers suggested potrace.$ convert input.jpg output.ppm \$ potrace -s output.ppm -o svgout.svg Results             ...

7

By default, iconv refuses to convert the file if it contains characters that do not exist in the target character set. Use //TRANSLIT to “downgrade” such characters. iconv -f utf-8 -t iso8859-1//TRANSLIT

7

Yes, there is. Though its name is djvutxt, not djvu2text. It is part of: the djvu package on Gentoo. the djvulibre-bin package on Debian/Ubuntu.

7

First of all, -aq sets a quality-based variable bit rate - I think you're looking for -ab (note that I'm an ffmpeg user, so my knowledge of avconv syntax is limited - I've no idea how far it's drifted since the fork). Regardless, the built-in avconv/ffmpeg AAC encoder is pretty bad. fdk_aac The only really good AAC encoder for avconv/ffmpeg is libfdk_aac ...

7

With a recent version of xclip (the -t option was added in 2010 but not released yet AFAICT, so you'd need to get it from subversion, or use the one packaged in Debian). xclip -o -selection clipboard -t text/html | pandoc -r html -w markdown And if you want to make that back into the clipboard: xclip -o -selection clipboard -t text/html | pandoc -r ...

6

sox version 13 and up supports FLAC, along with many other formats. sox can do many things to an audio file, not just convert from one format to another. It is to audio what ImageMagick is to graphics.

6

It is a double byte format, probably UTF-16. See if you can identify a BOM (Byter Order Mark) header at the beginning of the file. This will tell you the encoding if it is present, although it may not be. Note that a text editor may hide this from you, so you will probably need to look at the file with a hex dump utility such as od or something similar to ...

Only top voted, non community-wiki answers of a minimum length are eligible