Tag Info

Hot answers tagged

29

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 ...


28

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


24

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 = ...


18

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 ...


13

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 ...


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

xxd -b (source)


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

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.


9

Imagemagick can do it in one step: $ convert in.pdf -crop 50%x0 +repage out.pdf


9

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 ...


9

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 ...


8

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.


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

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


8

(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 ...


7

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, ...


7

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. ...


7

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 ...


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.


6

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


6

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


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 ...


6

Beyond strings I've never seen a Unix command line tool beyond grep, awk, and friends that can parse data from any text file. All these tools assume the data is in a textual format. Files such as PDF, or Word documents encode the textual data in a binary format thus rendering it inaccessible without the aid of other tools to parse it out. These tools are ...


6

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             ...


5

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 ...


5

I'm using Perl's xls2csv to convert xls files to csv. Not sure tho if it works with xlsx too. About: It can't be comma separated unfortunately since some columns have commas in them that's why quoting has been introduced: 1,2,"data,data, more data"


5

You can do this using bsdtar: ire@localhost: bsdtar -cvf pax.tar --format=pax @gnu.tar ire@localhost:file gnu.tar gnu.tar: POSIX tar archive (GNU) ire@localhost:file pax.tar pax.tar: POSIX tar archive @archive is the magic option. From the manpage: @archive (c and r mode only) The specified archive is opened and the entries in it will be ...


5

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 ...



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